diff --git a/cpp/dmi/sw_management_service.grpc.pb.cc b/cpp/dmi/sw_management_service.grpc.pb.cc
index 975b684..0aab698 100644
--- a/cpp/dmi/sw_management_service.grpc.pb.cc
+++ b/cpp/dmi/sw_management_service.grpc.pb.cc
@@ -28,6 +28,7 @@
   "/dmi.NativeSoftwareManagementService/RevertToStandbyImage",
   "/dmi.NativeSoftwareManagementService/UpdateStartupConfiguration",
   "/dmi.NativeSoftwareManagementService/GetStartupConfigurationInfo",
+  "/dmi.NativeSoftwareManagementService/UploadDebugInfo",
 };
 
 std::unique_ptr< NativeSoftwareManagementService::Stub> NativeSoftwareManagementService::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {
@@ -43,6 +44,7 @@
   , rpcmethod_RevertToStandbyImage_(NativeSoftwareManagementService_method_names[3], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
   , rpcmethod_UpdateStartupConfiguration_(NativeSoftwareManagementService_method_names[4], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
   , rpcmethod_GetStartupConfigurationInfo_(NativeSoftwareManagementService_method_names[5], ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
+  , rpcmethod_UploadDebugInfo_(NativeSoftwareManagementService_method_names[6], ::grpc::internal::RpcMethod::SERVER_STREAMING, channel)
   {}
 
 ::grpc::Status NativeSoftwareManagementService::Stub::GetSoftwareVersion(::grpc::ClientContext* context, const ::dmi::HardwareID& request, ::dmi::GetSoftwareVersionInformationResponse* response) {
@@ -165,6 +167,22 @@
   return ::grpc_impl::internal::ClientAsyncResponseReaderFactory< ::dmi::StartupConfigInfoResponse>::Create(channel_.get(), cq, rpcmethod_GetStartupConfigurationInfo_, context, request, false);
 }
 
+::grpc::ClientReader< ::dmi::UploadDebugInfoStatus>* NativeSoftwareManagementService::Stub::UploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request) {
+  return ::grpc_impl::internal::ClientReaderFactory< ::dmi::UploadDebugInfoStatus>::Create(channel_.get(), rpcmethod_UploadDebugInfo_, context, request);
+}
+
+void NativeSoftwareManagementService::Stub::experimental_async::UploadDebugInfo(::grpc::ClientContext* context, ::dmi::UploadDebugInfoRequest* request, ::grpc::experimental::ClientReadReactor< ::dmi::UploadDebugInfoStatus>* reactor) {
+  ::grpc_impl::internal::ClientCallbackReaderFactory< ::dmi::UploadDebugInfoStatus>::Create(stub_->channel_.get(), stub_->rpcmethod_UploadDebugInfo_, context, request, reactor);
+}
+
+::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>* NativeSoftwareManagementService::Stub::AsyncUploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
+  return ::grpc_impl::internal::ClientAsyncReaderFactory< ::dmi::UploadDebugInfoStatus>::Create(channel_.get(), cq, rpcmethod_UploadDebugInfo_, context, request, true, tag);
+}
+
+::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>* NativeSoftwareManagementService::Stub::PrepareAsyncUploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq) {
+  return ::grpc_impl::internal::ClientAsyncReaderFactory< ::dmi::UploadDebugInfoStatus>::Create(channel_.get(), cq, rpcmethod_UploadDebugInfo_, context, request, false, nullptr);
+}
+
 NativeSoftwareManagementService::Service::Service() {
   AddMethod(new ::grpc::internal::RpcServiceMethod(
       NativeSoftwareManagementService_method_names[0],
@@ -226,6 +244,16 @@
              ::dmi::StartupConfigInfoResponse* resp) {
                return service->GetStartupConfigurationInfo(ctx, req, resp);
              }, this)));
+  AddMethod(new ::grpc::internal::RpcServiceMethod(
+      NativeSoftwareManagementService_method_names[6],
+      ::grpc::internal::RpcMethod::SERVER_STREAMING,
+      new ::grpc::internal::ServerStreamingHandler< NativeSoftwareManagementService::Service, ::dmi::UploadDebugInfoRequest, ::dmi::UploadDebugInfoStatus>(
+          [](NativeSoftwareManagementService::Service* service,
+             ::grpc_impl::ServerContext* ctx,
+             const ::dmi::UploadDebugInfoRequest* req,
+             ::grpc_impl::ServerWriter<::dmi::UploadDebugInfoStatus>* writer) {
+               return service->UploadDebugInfo(ctx, req, writer);
+             }, this)));
 }
 
 NativeSoftwareManagementService::Service::~Service() {
@@ -273,6 +301,13 @@
   return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
 }
 
+::grpc::Status NativeSoftwareManagementService::Service::UploadDebugInfo(::grpc::ServerContext* context, const ::dmi::UploadDebugInfoRequest* request, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* writer) {
+  (void) context;
+  (void) request;
+  (void) writer;
+  return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+}
+
 
 }  // namespace dmi
 
diff --git a/cpp/dmi/sw_management_service.grpc.pb.h b/cpp/dmi/sw_management_service.grpc.pb.h
index 870e714..943da9f 100644
--- a/cpp/dmi/sw_management_service.grpc.pb.h
+++ b/cpp/dmi/sw_management_service.grpc.pb.h
@@ -95,6 +95,16 @@
     std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::dmi::StartupConfigInfoResponse>> PrepareAsyncGetStartupConfigurationInfo(::grpc::ClientContext* context, const ::dmi::StartupConfigInfoRequest& request, ::grpc::CompletionQueue* cq) {
       return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::dmi::StartupConfigInfoResponse>>(PrepareAsyncGetStartupConfigurationInfoRaw(context, request, cq));
     }
+    // This API can be used to upload to a remote location, information useful for troubleshooting problems on the hardware
+    std::unique_ptr< ::grpc::ClientReaderInterface< ::dmi::UploadDebugInfoStatus>> UploadDebugInfo(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request) {
+      return std::unique_ptr< ::grpc::ClientReaderInterface< ::dmi::UploadDebugInfoStatus>>(UploadDebugInfoRaw(context, request));
+    }
+    std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::dmi::UploadDebugInfoStatus>> AsyncUploadDebugInfo(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
+      return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::dmi::UploadDebugInfoStatus>>(AsyncUploadDebugInfoRaw(context, request, cq, tag));
+    }
+    std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::dmi::UploadDebugInfoStatus>> PrepareAsyncUploadDebugInfo(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq) {
+      return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::dmi::UploadDebugInfoStatus>>(PrepareAsyncUploadDebugInfoRaw(context, request, cq));
+    }
     class experimental_async_interface {
      public:
       virtual ~experimental_async_interface() {}
@@ -151,6 +161,12 @@
       #else
       virtual void GetStartupConfigurationInfo(::grpc::ClientContext* context, const ::grpc::ByteBuffer* request, ::dmi::StartupConfigInfoResponse* response, ::grpc::experimental::ClientUnaryReactor* reactor) = 0;
       #endif
+      // This API can be used to upload to a remote location, information useful for troubleshooting problems on the hardware
+      #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      virtual void UploadDebugInfo(::grpc::ClientContext* context, ::dmi::UploadDebugInfoRequest* request, ::grpc::ClientReadReactor< ::dmi::UploadDebugInfoStatus>* reactor) = 0;
+      #else
+      virtual void UploadDebugInfo(::grpc::ClientContext* context, ::dmi::UploadDebugInfoRequest* request, ::grpc::experimental::ClientReadReactor< ::dmi::UploadDebugInfoStatus>* reactor) = 0;
+      #endif
     };
     #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
     typedef class experimental_async_interface async_interface;
@@ -176,6 +192,9 @@
     virtual ::grpc::ClientAsyncReaderInterface< ::dmi::ConfigResponse>* PrepareAsyncUpdateStartupConfigurationRaw(::grpc::ClientContext* context, const ::dmi::ConfigRequest& request, ::grpc::CompletionQueue* cq) = 0;
     virtual ::grpc::ClientAsyncResponseReaderInterface< ::dmi::StartupConfigInfoResponse>* AsyncGetStartupConfigurationInfoRaw(::grpc::ClientContext* context, const ::dmi::StartupConfigInfoRequest& request, ::grpc::CompletionQueue* cq) = 0;
     virtual ::grpc::ClientAsyncResponseReaderInterface< ::dmi::StartupConfigInfoResponse>* PrepareAsyncGetStartupConfigurationInfoRaw(::grpc::ClientContext* context, const ::dmi::StartupConfigInfoRequest& request, ::grpc::CompletionQueue* cq) = 0;
+    virtual ::grpc::ClientReaderInterface< ::dmi::UploadDebugInfoStatus>* UploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request) = 0;
+    virtual ::grpc::ClientAsyncReaderInterface< ::dmi::UploadDebugInfoStatus>* AsyncUploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq, void* tag) = 0;
+    virtual ::grpc::ClientAsyncReaderInterface< ::dmi::UploadDebugInfoStatus>* PrepareAsyncUploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq) = 0;
   };
   class Stub final : public StubInterface {
    public:
@@ -230,6 +249,15 @@
     std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::dmi::StartupConfigInfoResponse>> PrepareAsyncGetStartupConfigurationInfo(::grpc::ClientContext* context, const ::dmi::StartupConfigInfoRequest& request, ::grpc::CompletionQueue* cq) {
       return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::dmi::StartupConfigInfoResponse>>(PrepareAsyncGetStartupConfigurationInfoRaw(context, request, cq));
     }
+    std::unique_ptr< ::grpc::ClientReader< ::dmi::UploadDebugInfoStatus>> UploadDebugInfo(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request) {
+      return std::unique_ptr< ::grpc::ClientReader< ::dmi::UploadDebugInfoStatus>>(UploadDebugInfoRaw(context, request));
+    }
+    std::unique_ptr< ::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>> AsyncUploadDebugInfo(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq, void* tag) {
+      return std::unique_ptr< ::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>>(AsyncUploadDebugInfoRaw(context, request, cq, tag));
+    }
+    std::unique_ptr< ::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>> PrepareAsyncUploadDebugInfo(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq) {
+      return std::unique_ptr< ::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>>(PrepareAsyncUploadDebugInfoRaw(context, request, cq));
+    }
     class experimental_async final :
       public StubInterface::experimental_async_interface {
      public:
@@ -277,6 +305,11 @@
       #else
       void GetStartupConfigurationInfo(::grpc::ClientContext* context, const ::grpc::ByteBuffer* request, ::dmi::StartupConfigInfoResponse* response, ::grpc::experimental::ClientUnaryReactor* reactor) override;
       #endif
+      #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      void UploadDebugInfo(::grpc::ClientContext* context, ::dmi::UploadDebugInfoRequest* request, ::grpc::ClientReadReactor< ::dmi::UploadDebugInfoStatus>* reactor) override;
+      #else
+      void UploadDebugInfo(::grpc::ClientContext* context, ::dmi::UploadDebugInfoRequest* request, ::grpc::experimental::ClientReadReactor< ::dmi::UploadDebugInfoStatus>* reactor) override;
+      #endif
      private:
       friend class Stub;
       explicit experimental_async(Stub* stub): stub_(stub) { }
@@ -304,12 +337,16 @@
     ::grpc::ClientAsyncReader< ::dmi::ConfigResponse>* PrepareAsyncUpdateStartupConfigurationRaw(::grpc::ClientContext* context, const ::dmi::ConfigRequest& request, ::grpc::CompletionQueue* cq) override;
     ::grpc::ClientAsyncResponseReader< ::dmi::StartupConfigInfoResponse>* AsyncGetStartupConfigurationInfoRaw(::grpc::ClientContext* context, const ::dmi::StartupConfigInfoRequest& request, ::grpc::CompletionQueue* cq) override;
     ::grpc::ClientAsyncResponseReader< ::dmi::StartupConfigInfoResponse>* PrepareAsyncGetStartupConfigurationInfoRaw(::grpc::ClientContext* context, const ::dmi::StartupConfigInfoRequest& request, ::grpc::CompletionQueue* cq) override;
+    ::grpc::ClientReader< ::dmi::UploadDebugInfoStatus>* UploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request) override;
+    ::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>* AsyncUploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq, void* tag) override;
+    ::grpc::ClientAsyncReader< ::dmi::UploadDebugInfoStatus>* PrepareAsyncUploadDebugInfoRaw(::grpc::ClientContext* context, const ::dmi::UploadDebugInfoRequest& request, ::grpc::CompletionQueue* cq) override;
     const ::grpc::internal::RpcMethod rpcmethod_GetSoftwareVersion_;
     const ::grpc::internal::RpcMethod rpcmethod_DownloadImage_;
     const ::grpc::internal::RpcMethod rpcmethod_ActivateImage_;
     const ::grpc::internal::RpcMethod rpcmethod_RevertToStandbyImage_;
     const ::grpc::internal::RpcMethod rpcmethod_UpdateStartupConfiguration_;
     const ::grpc::internal::RpcMethod rpcmethod_GetStartupConfigurationInfo_;
+    const ::grpc::internal::RpcMethod rpcmethod_UploadDebugInfo_;
   };
   static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());
 
@@ -332,6 +369,8 @@
     virtual ::grpc::Status UpdateStartupConfiguration(::grpc::ServerContext* context, const ::dmi::ConfigRequest* request, ::grpc::ServerWriter< ::dmi::ConfigResponse>* writer);
     // This API can be used to retrieve information about the current startup configuration that a device is using
     virtual ::grpc::Status GetStartupConfigurationInfo(::grpc::ServerContext* context, const ::dmi::StartupConfigInfoRequest* request, ::dmi::StartupConfigInfoResponse* response);
+    // This API can be used to upload to a remote location, information useful for troubleshooting problems on the hardware
+    virtual ::grpc::Status UploadDebugInfo(::grpc::ServerContext* context, const ::dmi::UploadDebugInfoRequest* request, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* writer);
   };
   template <class BaseClass>
   class WithAsyncMethod_GetSoftwareVersion : public BaseClass {
@@ -453,7 +492,27 @@
       ::grpc::Service::RequestAsyncUnary(5, context, request, response, new_call_cq, notification_cq, tag);
     }
   };
-  typedef WithAsyncMethod_GetSoftwareVersion<WithAsyncMethod_DownloadImage<WithAsyncMethod_ActivateImage<WithAsyncMethod_RevertToStandbyImage<WithAsyncMethod_UpdateStartupConfiguration<WithAsyncMethod_GetStartupConfigurationInfo<Service > > > > > > AsyncService;
+  template <class BaseClass>
+  class WithAsyncMethod_UploadDebugInfo : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithAsyncMethod_UploadDebugInfo() {
+      ::grpc::Service::MarkMethodAsync(6);
+    }
+    ~WithAsyncMethod_UploadDebugInfo() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status UploadDebugInfo(::grpc::ServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* /*writer*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    void RequestUploadDebugInfo(::grpc::ServerContext* context, ::dmi::UploadDebugInfoRequest* request, ::grpc::ServerAsyncWriter< ::dmi::UploadDebugInfoStatus>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+      ::grpc::Service::RequestAsyncServerStreaming(6, context, request, writer, new_call_cq, notification_cq, tag);
+    }
+  };
+  typedef WithAsyncMethod_GetSoftwareVersion<WithAsyncMethod_DownloadImage<WithAsyncMethod_ActivateImage<WithAsyncMethod_RevertToStandbyImage<WithAsyncMethod_UpdateStartupConfiguration<WithAsyncMethod_GetStartupConfigurationInfo<WithAsyncMethod_UploadDebugInfo<Service > > > > > > > AsyncService;
   template <class BaseClass>
   class ExperimentalWithCallbackMethod_GetSoftwareVersion : public BaseClass {
    private:
@@ -700,11 +759,49 @@
     #endif
       { return nullptr; }
   };
+  template <class BaseClass>
+  class ExperimentalWithCallbackMethod_UploadDebugInfo : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    ExperimentalWithCallbackMethod_UploadDebugInfo() {
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      ::grpc::Service::
+    #else
+      ::grpc::Service::experimental().
+    #endif
+        MarkMethodCallback(6,
+          new ::grpc_impl::internal::CallbackServerStreamingHandler< ::dmi::UploadDebugInfoRequest, ::dmi::UploadDebugInfoStatus>(
+            [this](
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+                   ::grpc::CallbackServerContext*
+    #else
+                   ::grpc::experimental::CallbackServerContext*
+    #endif
+                     context, const ::dmi::UploadDebugInfoRequest* request) { return this->UploadDebugInfo(context, request); }));
+    }
+    ~ExperimentalWithCallbackMethod_UploadDebugInfo() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status UploadDebugInfo(::grpc::ServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* /*writer*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+    virtual ::grpc::ServerWriteReactor< ::dmi::UploadDebugInfoStatus>* UploadDebugInfo(
+      ::grpc::CallbackServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/)
+    #else
+    virtual ::grpc::experimental::ServerWriteReactor< ::dmi::UploadDebugInfoStatus>* UploadDebugInfo(
+      ::grpc::experimental::CallbackServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/)
+    #endif
+      { return nullptr; }
+  };
   #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
-  typedef ExperimentalWithCallbackMethod_GetSoftwareVersion<ExperimentalWithCallbackMethod_DownloadImage<ExperimentalWithCallbackMethod_ActivateImage<ExperimentalWithCallbackMethod_RevertToStandbyImage<ExperimentalWithCallbackMethod_UpdateStartupConfiguration<ExperimentalWithCallbackMethod_GetStartupConfigurationInfo<Service > > > > > > CallbackService;
+  typedef ExperimentalWithCallbackMethod_GetSoftwareVersion<ExperimentalWithCallbackMethod_DownloadImage<ExperimentalWithCallbackMethod_ActivateImage<ExperimentalWithCallbackMethod_RevertToStandbyImage<ExperimentalWithCallbackMethod_UpdateStartupConfiguration<ExperimentalWithCallbackMethod_GetStartupConfigurationInfo<ExperimentalWithCallbackMethod_UploadDebugInfo<Service > > > > > > > CallbackService;
   #endif
 
-  typedef ExperimentalWithCallbackMethod_GetSoftwareVersion<ExperimentalWithCallbackMethod_DownloadImage<ExperimentalWithCallbackMethod_ActivateImage<ExperimentalWithCallbackMethod_RevertToStandbyImage<ExperimentalWithCallbackMethod_UpdateStartupConfiguration<ExperimentalWithCallbackMethod_GetStartupConfigurationInfo<Service > > > > > > ExperimentalCallbackService;
+  typedef ExperimentalWithCallbackMethod_GetSoftwareVersion<ExperimentalWithCallbackMethod_DownloadImage<ExperimentalWithCallbackMethod_ActivateImage<ExperimentalWithCallbackMethod_RevertToStandbyImage<ExperimentalWithCallbackMethod_UpdateStartupConfiguration<ExperimentalWithCallbackMethod_GetStartupConfigurationInfo<ExperimentalWithCallbackMethod_UploadDebugInfo<Service > > > > > > > ExperimentalCallbackService;
   template <class BaseClass>
   class WithGenericMethod_GetSoftwareVersion : public BaseClass {
    private:
@@ -808,6 +905,23 @@
     }
   };
   template <class BaseClass>
+  class WithGenericMethod_UploadDebugInfo : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithGenericMethod_UploadDebugInfo() {
+      ::grpc::Service::MarkMethodGeneric(6);
+    }
+    ~WithGenericMethod_UploadDebugInfo() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status UploadDebugInfo(::grpc::ServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* /*writer*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+  };
+  template <class BaseClass>
   class WithRawMethod_GetSoftwareVersion : public BaseClass {
    private:
     void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
@@ -928,6 +1042,26 @@
     }
   };
   template <class BaseClass>
+  class WithRawMethod_UploadDebugInfo : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithRawMethod_UploadDebugInfo() {
+      ::grpc::Service::MarkMethodRaw(6);
+    }
+    ~WithRawMethod_UploadDebugInfo() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status UploadDebugInfo(::grpc::ServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* /*writer*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    void RequestUploadDebugInfo(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncWriter< ::grpc::ByteBuffer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) {
+      ::grpc::Service::RequestAsyncServerStreaming(6, context, request, writer, new_call_cq, notification_cq, tag);
+    }
+  };
+  template <class BaseClass>
   class ExperimentalWithRawCallbackMethod_GetSoftwareVersion : public BaseClass {
    private:
     void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
@@ -1156,6 +1290,44 @@
       { return nullptr; }
   };
   template <class BaseClass>
+  class ExperimentalWithRawCallbackMethod_UploadDebugInfo : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    ExperimentalWithRawCallbackMethod_UploadDebugInfo() {
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+      ::grpc::Service::
+    #else
+      ::grpc::Service::experimental().
+    #endif
+        MarkMethodRawCallback(6,
+          new ::grpc_impl::internal::CallbackServerStreamingHandler< ::grpc::ByteBuffer, ::grpc::ByteBuffer>(
+            [this](
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+                   ::grpc::CallbackServerContext*
+    #else
+                   ::grpc::experimental::CallbackServerContext*
+    #endif
+                     context, const::grpc::ByteBuffer* request) { return this->UploadDebugInfo(context, request); }));
+    }
+    ~ExperimentalWithRawCallbackMethod_UploadDebugInfo() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable synchronous version of this method
+    ::grpc::Status UploadDebugInfo(::grpc::ServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* /*writer*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
+    virtual ::grpc::ServerWriteReactor< ::grpc::ByteBuffer>* UploadDebugInfo(
+      ::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/)
+    #else
+    virtual ::grpc::experimental::ServerWriteReactor< ::grpc::ByteBuffer>* UploadDebugInfo(
+      ::grpc::experimental::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/)
+    #endif
+      { return nullptr; }
+  };
+  template <class BaseClass>
   class WithStreamedUnaryMethod_GetSoftwareVersion : public BaseClass {
    private:
     void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
@@ -1318,8 +1490,35 @@
     // replace default version of method with split streamed
     virtual ::grpc::Status StreamedUpdateStartupConfiguration(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< ::dmi::ConfigRequest,::dmi::ConfigResponse>* server_split_streamer) = 0;
   };
-  typedef WithSplitStreamingMethod_DownloadImage<WithSplitStreamingMethod_ActivateImage<WithSplitStreamingMethod_RevertToStandbyImage<WithSplitStreamingMethod_UpdateStartupConfiguration<Service > > > > SplitStreamedService;
-  typedef WithStreamedUnaryMethod_GetSoftwareVersion<WithSplitStreamingMethod_DownloadImage<WithSplitStreamingMethod_ActivateImage<WithSplitStreamingMethod_RevertToStandbyImage<WithSplitStreamingMethod_UpdateStartupConfiguration<WithStreamedUnaryMethod_GetStartupConfigurationInfo<Service > > > > > > StreamedService;
+  template <class BaseClass>
+  class WithSplitStreamingMethod_UploadDebugInfo : public BaseClass {
+   private:
+    void BaseClassMustBeDerivedFromService(const Service* /*service*/) {}
+   public:
+    WithSplitStreamingMethod_UploadDebugInfo() {
+      ::grpc::Service::MarkMethodStreamed(6,
+        new ::grpc::internal::SplitServerStreamingHandler<
+          ::dmi::UploadDebugInfoRequest, ::dmi::UploadDebugInfoStatus>(
+            [this](::grpc_impl::ServerContext* context,
+                   ::grpc_impl::ServerSplitStreamer<
+                     ::dmi::UploadDebugInfoRequest, ::dmi::UploadDebugInfoStatus>* streamer) {
+                       return this->StreamedUploadDebugInfo(context,
+                         streamer);
+                  }));
+    }
+    ~WithSplitStreamingMethod_UploadDebugInfo() override {
+      BaseClassMustBeDerivedFromService(this);
+    }
+    // disable regular version of this method
+    ::grpc::Status UploadDebugInfo(::grpc::ServerContext* /*context*/, const ::dmi::UploadDebugInfoRequest* /*request*/, ::grpc::ServerWriter< ::dmi::UploadDebugInfoStatus>* /*writer*/) override {
+      abort();
+      return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
+    }
+    // replace default version of method with split streamed
+    virtual ::grpc::Status StreamedUploadDebugInfo(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< ::dmi::UploadDebugInfoRequest,::dmi::UploadDebugInfoStatus>* server_split_streamer) = 0;
+  };
+  typedef WithSplitStreamingMethod_DownloadImage<WithSplitStreamingMethod_ActivateImage<WithSplitStreamingMethod_RevertToStandbyImage<WithSplitStreamingMethod_UpdateStartupConfiguration<WithSplitStreamingMethod_UploadDebugInfo<Service > > > > > SplitStreamedService;
+  typedef WithStreamedUnaryMethod_GetSoftwareVersion<WithSplitStreamingMethod_DownloadImage<WithSplitStreamingMethod_ActivateImage<WithSplitStreamingMethod_RevertToStandbyImage<WithSplitStreamingMethod_UpdateStartupConfiguration<WithStreamedUnaryMethod_GetStartupConfigurationInfo<WithSplitStreamingMethod_UploadDebugInfo<Service > > > > > > > StreamedService;
 };
 
 }  // namespace dmi
diff --git a/cpp/dmi/sw_management_service.pb.cc b/cpp/dmi/sw_management_service.pb.cc
index 508dd63..1fc0e00 100644
--- a/cpp/dmi/sw_management_service.pb.cc
+++ b/cpp/dmi/sw_management_service.pb.cc
@@ -49,6 +49,14 @@
  public:
   ::google::protobuf::internal::ExplicitlyConstructed<StartupConfigInfoResponse> _instance;
 } _StartupConfigInfoResponse_default_instance_;
+class UploadDebugInfoRequestDefaultTypeInternal {
+ public:
+  ::google::protobuf::internal::ExplicitlyConstructed<UploadDebugInfoRequest> _instance;
+} _UploadDebugInfoRequest_default_instance_;
+class UploadDebugInfoStatusDefaultTypeInternal {
+ public:
+  ::google::protobuf::internal::ExplicitlyConstructed<UploadDebugInfoStatus> _instance;
+} _UploadDebugInfoStatus_default_instance_;
 }  // namespace dmi
 static void InitDefaultsSoftwareVersionInformation_dmi_2fsw_5fmanagement_5fservice_2eproto() {
   GOOGLE_PROTOBUF_VERIFY_VERSION;
@@ -154,6 +162,36 @@
 ::google::protobuf::internal::SCCInfo<0> scc_info_StartupConfigInfoResponse_dmi_2fsw_5fmanagement_5fservice_2eproto =
     {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 0, InitDefaultsStartupConfigInfoResponse_dmi_2fsw_5fmanagement_5fservice_2eproto}, {}};
 
+static void InitDefaultsUploadDebugInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto() {
+  GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+  {
+    void* ptr = &::dmi::_UploadDebugInfoRequest_default_instance_;
+    new (ptr) ::dmi::UploadDebugInfoRequest();
+    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
+  }
+  ::dmi::UploadDebugInfoRequest::InitAsDefaultInstance();
+}
+
+::google::protobuf::internal::SCCInfo<1> scc_info_UploadDebugInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto =
+    {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsUploadDebugInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto}, {
+      &scc_info_Uuid_dmi_2fhw_2eproto.base,}};
+
+static void InitDefaultsUploadDebugInfoStatus_dmi_2fsw_5fmanagement_5fservice_2eproto() {
+  GOOGLE_PROTOBUF_VERIFY_VERSION;
+
+  {
+    void* ptr = &::dmi::_UploadDebugInfoStatus_default_instance_;
+    new (ptr) ::dmi::UploadDebugInfoStatus();
+    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
+  }
+  ::dmi::UploadDebugInfoStatus::InitAsDefaultInstance();
+}
+
+::google::protobuf::internal::SCCInfo<1> scc_info_UploadDebugInfoStatus_dmi_2fsw_5fmanagement_5fservice_2eproto =
+    {{ATOMIC_VAR_INIT(::google::protobuf::internal::SCCInfoBase::kUninitialized), 1, InitDefaultsUploadDebugInfoStatus_dmi_2fsw_5fmanagement_5fservice_2eproto}, {
+      &scc_info_Uuid_dmi_2fhw_2eproto.base,}};
+
 void InitDefaults_dmi_2fsw_5fmanagement_5fservice_2eproto() {
   ::google::protobuf::internal::InitSCC(&scc_info_SoftwareVersionInformation_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
   ::google::protobuf::internal::InitSCC(&scc_info_GetSoftwareVersionInformationResponse_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
@@ -162,10 +200,12 @@
   ::google::protobuf::internal::InitSCC(&scc_info_ConfigResponse_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
   ::google::protobuf::internal::InitSCC(&scc_info_StartupConfigInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
   ::google::protobuf::internal::InitSCC(&scc_info_StartupConfigInfoResponse_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
+  ::google::protobuf::internal::InitSCC(&scc_info_UploadDebugInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
+  ::google::protobuf::internal::InitSCC(&scc_info_UploadDebugInfoStatus_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
 }
 
-::google::protobuf::Metadata file_level_metadata_dmi_2fsw_5fmanagement_5fservice_2eproto[7];
-const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto[3];
+::google::protobuf::Metadata file_level_metadata_dmi_2fsw_5fmanagement_5fservice_2eproto[9];
+const ::google::protobuf::EnumDescriptor* file_level_enum_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto[5];
 constexpr ::google::protobuf::ServiceDescriptor const** file_level_service_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto = nullptr;
 
 const ::google::protobuf::uint32 TableStruct_dmi_2fsw_5fmanagement_5fservice_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
@@ -223,6 +263,24 @@
   PROTOBUF_FIELD_OFFSET(::dmi::StartupConfigInfoResponse, config_url_),
   PROTOBUF_FIELD_OFFSET(::dmi::StartupConfigInfoResponse, version_),
   PROTOBUF_FIELD_OFFSET(::dmi::StartupConfigInfoResponse, reason_detail_),
+  ~0u,  // no _has_bits_
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoRequest, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  ~0u,  // no _weak_field_map_
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoRequest, device_uuid_),
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoRequest, location_url_),
+  ~0u,  // no _has_bits_
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, _internal_metadata_),
+  ~0u,  // no _extensions_
+  ~0u,  // no _oneof_case_
+  ~0u,  // no _weak_field_map_
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, device_uuid_),
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, status_),
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, percent_uploaded_),
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, reason_),
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, location_url_),
+  PROTOBUF_FIELD_OFFSET(::dmi::UploadDebugInfoStatus, file_name_),
 };
 static const ::google::protobuf::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
   { 0, -1, sizeof(::dmi::SoftwareVersionInformation)},
@@ -232,6 +290,8 @@
   { 30, -1, sizeof(::dmi::ConfigResponse)},
   { 38, -1, sizeof(::dmi::StartupConfigInfoRequest)},
   { 44, -1, sizeof(::dmi::StartupConfigInfoResponse)},
+  { 54, -1, sizeof(::dmi::UploadDebugInfoRequest)},
+  { 61, -1, sizeof(::dmi::UploadDebugInfoStatus)},
 };
 
 static ::google::protobuf::Message const * const file_default_instances[] = {
@@ -242,12 +302,14 @@
   reinterpret_cast<const ::google::protobuf::Message*>(&::dmi::_ConfigResponse_default_instance_),
   reinterpret_cast<const ::google::protobuf::Message*>(&::dmi::_StartupConfigInfoRequest_default_instance_),
   reinterpret_cast<const ::google::protobuf::Message*>(&::dmi::_StartupConfigInfoResponse_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&::dmi::_UploadDebugInfoRequest_default_instance_),
+  reinterpret_cast<const ::google::protobuf::Message*>(&::dmi::_UploadDebugInfoStatus_default_instance_),
 };
 
 ::google::protobuf::internal::AssignDescriptorsTable assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto = {
   {}, AddDescriptors_dmi_2fsw_5fmanagement_5fservice_2eproto, "dmi/sw_management_service.proto", schemas,
   file_default_instances, TableStruct_dmi_2fsw_5fmanagement_5fservice_2eproto::offsets,
-  file_level_metadata_dmi_2fsw_5fmanagement_5fservice_2eproto, 7, file_level_enum_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto, file_level_service_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto,
+  file_level_metadata_dmi_2fsw_5fmanagement_5fservice_2eproto, 9, file_level_enum_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto, file_level_service_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto,
 };
 
 const char descriptor_table_protodef_dmi_2fsw_5fmanagement_5fservice_2eproto[] =
@@ -283,25 +345,42 @@
   "_url\030\003 \001(\t\022\017\n\007version\030\004 \001(\t\022\025\n\rreason_de"
   "tail\030\005 \001(\t\"^\n\006Reason\022\024\n\020UNDEFINED_REASON"
   "\020\000\022\022\n\016UNKNOWN_DEVICE\020\001\022\022\n\016INTERNAL_ERROR"
-  "\020\002\022\026\n\022DEVICE_UNREACHABLE\020\0032\316\003\n\037NativeSof"
-  "twareManagementService\022Q\n\022GetSoftwareVer"
-  "sion\022\017.dmi.HardwareID\032*.dmi.GetSoftwareV"
-  "ersionInformationResponse\022>\n\rDownloadIma"
-  "ge\022\031.dmi.DownloadImageRequest\032\020.dmi.Imag"
-  "eStatus0\001\0224\n\rActivateImage\022\017.dmi.Hardwar"
-  "eID\032\020.dmi.ImageStatus0\001\022;\n\024RevertToStand"
-  "byImage\022\017.dmi.HardwareID\032\020.dmi.ImageStat"
-  "us0\001\022G\n\032UpdateStartupConfiguration\022\022.dmi"
-  ".ConfigRequest\032\023.dmi.ConfigResponse0\001\022\\\n"
-  "\033GetStartupConfigurationInfo\022\035.dmi.Start"
-  "upConfigInfoRequest\032\036.dmi.StartupConfigI"
-  "nfoResponseB;Z9github.com/opencord/devic"
-  "e-management-interface/v3/go/dmib\006proto3"
+  "\020\002\022\026\n\022DEVICE_UNREACHABLE\020\003\"N\n\026UploadDebu"
+  "gInfoRequest\022\036\n\013device_uuid\030\001 \001(\0132\t.dmi."
+  "Uuid\022\024\n\014location_url\030\003 \001(\t\"\377\003\n\025UploadDeb"
+  "ugInfoStatus\022\036\n\013device_uuid\030\001 \001(\0132\t.dmi."
+  "Uuid\0227\n\006status\030\002 \001(\0162\'.dmi.UploadDebugIn"
+  "foStatus.UploadStatus\022\030\n\020percent_uploade"
+  "d\030\003 \001(\005\0221\n\006reason\030\004 \001(\0162!.dmi.UploadDebu"
+  "gInfoStatus.Reason\022\024\n\014location_url\030\005 \001(\t"
+  "\022\021\n\tfile_name\030\006 \001(\t\"U\n\014UploadStatus\022\033\n\027U"
+  "NDEFINED_UPLOAD_STATUS\020\000\022\014\n\010COMPLETE\020\001\022\017"
+  "\n\013IN_PROGRESS\020\002\022\t\n\005ERROR\020\003\"\277\001\n\006Reason\022\024\n"
+  "\020UNDEFINED_REASON\020\000\022\022\n\016UNKNOWN_DEVICE\020\001\022"
+  "\022\n\016INTERNAL_ERROR\020\002\022\026\n\022DEVICE_UNREACHABL"
+  "E\020\003\022\037\n\033REMOTE_LOCATION_UNREACHABLE\020\004\022%\n!"
+  "REMOTE_LOCATION_PERMISSION_DENIED\020\005\022\027\n\023E"
+  "RROR_DURING_UPLOAD\020\0062\234\004\n\037NativeSoftwareM"
+  "anagementService\022Q\n\022GetSoftwareVersion\022\017"
+  ".dmi.HardwareID\032*.dmi.GetSoftwareVersion"
+  "InformationResponse\022>\n\rDownloadImage\022\031.d"
+  "mi.DownloadImageRequest\032\020.dmi.ImageStatu"
+  "s0\001\0224\n\rActivateImage\022\017.dmi.HardwareID\032\020."
+  "dmi.ImageStatus0\001\022;\n\024RevertToStandbyImag"
+  "e\022\017.dmi.HardwareID\032\020.dmi.ImageStatus0\001\022G"
+  "\n\032UpdateStartupConfiguration\022\022.dmi.Confi"
+  "gRequest\032\023.dmi.ConfigResponse0\001\022\\\n\033GetSt"
+  "artupConfigurationInfo\022\035.dmi.StartupConf"
+  "igInfoRequest\032\036.dmi.StartupConfigInfoRes"
+  "ponse\022L\n\017UploadDebugInfo\022\033.dmi.UploadDeb"
+  "ugInfoRequest\032\032.dmi.UploadDebugInfoStatu"
+  "s0\001B;Z9github.com/opencord/device-manage"
+  "ment-interface/v3/go/dmib\006proto3"
   ;
 ::google::protobuf::internal::DescriptorTable descriptor_table_dmi_2fsw_5fmanagement_5fservice_2eproto = {
   false, InitDefaults_dmi_2fsw_5fmanagement_5fservice_2eproto, 
   descriptor_table_protodef_dmi_2fsw_5fmanagement_5fservice_2eproto,
-  "dmi/sw_management_service.proto", &assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto, 1840,
+  "dmi/sw_management_service.proto", &assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto, 2512,
 };
 
 void AddDescriptors_dmi_2fsw_5fmanagement_5fservice_2eproto() {
@@ -398,6 +477,62 @@
 const StartupConfigInfoResponse_Reason StartupConfigInfoResponse::Reason_MAX;
 const int StartupConfigInfoResponse::Reason_ARRAYSIZE;
 #endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* UploadDebugInfoStatus_UploadStatus_descriptor() {
+  ::google::protobuf::internal::AssignDescriptors(&assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto);
+  return file_level_enum_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto[3];
+}
+bool UploadDebugInfoStatus_UploadStatus_IsValid(int value) {
+  switch (value) {
+    case 0:
+    case 1:
+    case 2:
+    case 3:
+      return true;
+    default:
+      return false;
+  }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::UNDEFINED_UPLOAD_STATUS;
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::COMPLETE;
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::IN_PROGRESS;
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::ERROR;
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::UploadStatus_MIN;
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::UploadStatus_MAX;
+const int UploadDebugInfoStatus::UploadStatus_ARRAYSIZE;
+#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
+const ::google::protobuf::EnumDescriptor* UploadDebugInfoStatus_Reason_descriptor() {
+  ::google::protobuf::internal::AssignDescriptors(&assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto);
+  return file_level_enum_descriptors_dmi_2fsw_5fmanagement_5fservice_2eproto[4];
+}
+bool UploadDebugInfoStatus_Reason_IsValid(int value) {
+  switch (value) {
+    case 0:
+    case 1:
+    case 2:
+    case 3:
+    case 4:
+    case 5:
+    case 6:
+      return true;
+    default:
+      return false;
+  }
+}
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::UNDEFINED_REASON;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::UNKNOWN_DEVICE;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::INTERNAL_ERROR;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::DEVICE_UNREACHABLE;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::REMOTE_LOCATION_UNREACHABLE;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::REMOTE_LOCATION_PERMISSION_DENIED;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::ERROR_DURING_UPLOAD;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::Reason_MIN;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus::Reason_MAX;
+const int UploadDebugInfoStatus::Reason_ARRAYSIZE;
+#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
 
 // ===================================================================
 
@@ -3175,6 +3310,959 @@
 }
 
 
+// ===================================================================
+
+void UploadDebugInfoRequest::InitAsDefaultInstance() {
+  ::dmi::_UploadDebugInfoRequest_default_instance_._instance.get_mutable()->device_uuid_ = const_cast< ::dmi::Uuid*>(
+      ::dmi::Uuid::internal_default_instance());
+}
+class UploadDebugInfoRequest::HasBitSetters {
+ public:
+  static const ::dmi::Uuid& device_uuid(const UploadDebugInfoRequest* msg);
+};
+
+const ::dmi::Uuid&
+UploadDebugInfoRequest::HasBitSetters::device_uuid(const UploadDebugInfoRequest* msg) {
+  return *msg->device_uuid_;
+}
+void UploadDebugInfoRequest::clear_device_uuid() {
+  if (GetArenaNoVirtual() == nullptr && device_uuid_ != nullptr) {
+    delete device_uuid_;
+  }
+  device_uuid_ = nullptr;
+}
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int UploadDebugInfoRequest::kDeviceUuidFieldNumber;
+const int UploadDebugInfoRequest::kLocationUrlFieldNumber;
+#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+UploadDebugInfoRequest::UploadDebugInfoRequest()
+  : ::google::protobuf::Message(), _internal_metadata_(nullptr) {
+  SharedCtor();
+  // @@protoc_insertion_point(constructor:dmi.UploadDebugInfoRequest)
+}
+UploadDebugInfoRequest::UploadDebugInfoRequest(const UploadDebugInfoRequest& from)
+  : ::google::protobuf::Message(),
+      _internal_metadata_(nullptr) {
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  location_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.location_url().size() > 0) {
+    location_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.location_url_);
+  }
+  if (from.has_device_uuid()) {
+    device_uuid_ = new ::dmi::Uuid(*from.device_uuid_);
+  } else {
+    device_uuid_ = nullptr;
+  }
+  // @@protoc_insertion_point(copy_constructor:dmi.UploadDebugInfoRequest)
+}
+
+void UploadDebugInfoRequest::SharedCtor() {
+  ::google::protobuf::internal::InitSCC(
+      &scc_info_UploadDebugInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
+  location_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  device_uuid_ = nullptr;
+}
+
+UploadDebugInfoRequest::~UploadDebugInfoRequest() {
+  // @@protoc_insertion_point(destructor:dmi.UploadDebugInfoRequest)
+  SharedDtor();
+}
+
+void UploadDebugInfoRequest::SharedDtor() {
+  location_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (this != internal_default_instance()) delete device_uuid_;
+}
+
+void UploadDebugInfoRequest::SetCachedSize(int size) const {
+  _cached_size_.Set(size);
+}
+const UploadDebugInfoRequest& UploadDebugInfoRequest::default_instance() {
+  ::google::protobuf::internal::InitSCC(&::scc_info_UploadDebugInfoRequest_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
+  return *internal_default_instance();
+}
+
+
+void UploadDebugInfoRequest::Clear() {
+// @@protoc_insertion_point(message_clear_start:dmi.UploadDebugInfoRequest)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  // Prevent compiler warnings about cached_has_bits being unused
+  (void) cached_has_bits;
+
+  location_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (GetArenaNoVirtual() == nullptr && device_uuid_ != nullptr) {
+    delete device_uuid_;
+  }
+  device_uuid_ = nullptr;
+  _internal_metadata_.Clear();
+}
+
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+const char* UploadDebugInfoRequest::_InternalParse(const char* begin, const char* end, void* object,
+                  ::google::protobuf::internal::ParseContext* ctx) {
+  auto msg = static_cast<UploadDebugInfoRequest*>(object);
+  ::google::protobuf::int32 size; (void)size;
+  int depth; (void)depth;
+  ::google::protobuf::uint32 tag;
+  ::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
+  auto ptr = begin;
+  while (ptr < end) {
+    ptr = ::google::protobuf::io::Parse32(ptr, &tag);
+    GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+    switch (tag >> 3) {
+      // .dmi.Uuid device_uuid = 1;
+      case 1: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
+        ptr = ::google::protobuf::io::ReadSize(ptr, &size);
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        parser_till_end = ::dmi::Uuid::_InternalParse;
+        object = msg->mutable_device_uuid();
+        if (size > end - ptr) goto len_delim_till_end;
+        ptr += size;
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+            {parser_till_end, object}, ptr - size, ptr));
+        break;
+      }
+      // string location_url = 3;
+      case 3: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 26) goto handle_unusual;
+        ptr = ::google::protobuf::io::ReadSize(ptr, &size);
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        ctx->extra_parse_data().SetFieldName("dmi.UploadDebugInfoRequest.location_url");
+        object = msg->mutable_location_url();
+        if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
+          parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
+          goto string_till_end;
+        }
+        GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
+        ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
+        ptr += size;
+        break;
+      }
+      default: {
+      handle_unusual:
+        if ((tag & 7) == 4 || tag == 0) {
+          ctx->EndGroup(tag);
+          return ptr;
+        }
+        auto res = UnknownFieldParse(tag, {_InternalParse, msg},
+          ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
+        ptr = res.first;
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
+        if (res.second) return ptr;
+      }
+    }  // switch
+  }  // while
+  return ptr;
+string_till_end:
+  static_cast<::std::string*>(object)->clear();
+  static_cast<::std::string*>(object)->reserve(size);
+  goto len_delim_till_end;
+len_delim_till_end:
+  return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
+                               {parser_till_end, object}, size);
+}
+#else  // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+bool UploadDebugInfoRequest::MergePartialFromCodedStream(
+    ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+  ::google::protobuf::uint32 tag;
+  // @@protoc_insertion_point(parse_start:dmi.UploadDebugInfoRequest)
+  for (;;) {
+    ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+    tag = p.first;
+    if (!p.second) goto handle_unusual;
+    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+      // .dmi.Uuid device_uuid = 1;
+      case 1: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+               input, mutable_device_uuid()));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // string location_url = 3;
+      case 3: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (26 & 0xFF)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_location_url()));
+          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+            this->location_url().data(), static_cast<int>(this->location_url().length()),
+            ::google::protobuf::internal::WireFormatLite::PARSE,
+            "dmi.UploadDebugInfoRequest.location_url"));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      default: {
+      handle_unusual:
+        if (tag == 0) {
+          goto success;
+        }
+        DO_(::google::protobuf::internal::WireFormat::SkipField(
+              input, tag, _internal_metadata_.mutable_unknown_fields()));
+        break;
+      }
+    }
+  }
+success:
+  // @@protoc_insertion_point(parse_success:dmi.UploadDebugInfoRequest)
+  return true;
+failure:
+  // @@protoc_insertion_point(parse_failure:dmi.UploadDebugInfoRequest)
+  return false;
+#undef DO_
+}
+#endif  // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+
+void UploadDebugInfoRequest::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // @@protoc_insertion_point(serialize_start:dmi.UploadDebugInfoRequest)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  // .dmi.Uuid device_uuid = 1;
+  if (this->has_device_uuid()) {
+    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+      1, HasBitSetters::device_uuid(this), output);
+  }
+
+  // string location_url = 3;
+  if (this->location_url().size() > 0) {
+    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+      this->location_url().data(), static_cast<int>(this->location_url().length()),
+      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
+      "dmi.UploadDebugInfoRequest.location_url");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      3, this->location_url(), output);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+        _internal_metadata_.unknown_fields(), output);
+  }
+  // @@protoc_insertion_point(serialize_end:dmi.UploadDebugInfoRequest)
+}
+
+::google::protobuf::uint8* UploadDebugInfoRequest::InternalSerializeWithCachedSizesToArray(
+    ::google::protobuf::uint8* target) const {
+  // @@protoc_insertion_point(serialize_to_array_start:dmi.UploadDebugInfoRequest)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  // .dmi.Uuid device_uuid = 1;
+  if (this->has_device_uuid()) {
+    target = ::google::protobuf::internal::WireFormatLite::
+      InternalWriteMessageToArray(
+        1, HasBitSetters::device_uuid(this), target);
+  }
+
+  // string location_url = 3;
+  if (this->location_url().size() > 0) {
+    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+      this->location_url().data(), static_cast<int>(this->location_url().length()),
+      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
+      "dmi.UploadDebugInfoRequest.location_url");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        3, this->location_url(), target);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+        _internal_metadata_.unknown_fields(), target);
+  }
+  // @@protoc_insertion_point(serialize_to_array_end:dmi.UploadDebugInfoRequest)
+  return target;
+}
+
+size_t UploadDebugInfoRequest::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:dmi.UploadDebugInfoRequest)
+  size_t total_size = 0;
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    total_size +=
+      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+        _internal_metadata_.unknown_fields());
+  }
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  // Prevent compiler warnings about cached_has_bits being unused
+  (void) cached_has_bits;
+
+  // string location_url = 3;
+  if (this->location_url().size() > 0) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->location_url());
+  }
+
+  // .dmi.Uuid device_uuid = 1;
+  if (this->has_device_uuid()) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::MessageSize(
+        *device_uuid_);
+  }
+
+  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+  SetCachedSize(cached_size);
+  return total_size;
+}
+
+void UploadDebugInfoRequest::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:dmi.UploadDebugInfoRequest)
+  GOOGLE_DCHECK_NE(&from, this);
+  const UploadDebugInfoRequest* source =
+      ::google::protobuf::DynamicCastToGenerated<UploadDebugInfoRequest>(
+          &from);
+  if (source == nullptr) {
+  // @@protoc_insertion_point(generalized_merge_from_cast_fail:dmi.UploadDebugInfoRequest)
+    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+  } else {
+  // @@protoc_insertion_point(generalized_merge_from_cast_success:dmi.UploadDebugInfoRequest)
+    MergeFrom(*source);
+  }
+}
+
+void UploadDebugInfoRequest::MergeFrom(const UploadDebugInfoRequest& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:dmi.UploadDebugInfoRequest)
+  GOOGLE_DCHECK_NE(&from, this);
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  if (from.location_url().size() > 0) {
+
+    location_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.location_url_);
+  }
+  if (from.has_device_uuid()) {
+    mutable_device_uuid()->::dmi::Uuid::MergeFrom(from.device_uuid());
+  }
+}
+
+void UploadDebugInfoRequest::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:dmi.UploadDebugInfoRequest)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+void UploadDebugInfoRequest::CopyFrom(const UploadDebugInfoRequest& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:dmi.UploadDebugInfoRequest)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool UploadDebugInfoRequest::IsInitialized() const {
+  return true;
+}
+
+void UploadDebugInfoRequest::Swap(UploadDebugInfoRequest* other) {
+  if (other == this) return;
+  InternalSwap(other);
+}
+void UploadDebugInfoRequest::InternalSwap(UploadDebugInfoRequest* other) {
+  using std::swap;
+  _internal_metadata_.Swap(&other->_internal_metadata_);
+  location_url_.Swap(&other->location_url_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+    GetArenaNoVirtual());
+  swap(device_uuid_, other->device_uuid_);
+}
+
+::google::protobuf::Metadata UploadDebugInfoRequest::GetMetadata() const {
+  ::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto);
+  return ::file_level_metadata_dmi_2fsw_5fmanagement_5fservice_2eproto[kIndexInFileMessages];
+}
+
+
+// ===================================================================
+
+void UploadDebugInfoStatus::InitAsDefaultInstance() {
+  ::dmi::_UploadDebugInfoStatus_default_instance_._instance.get_mutable()->device_uuid_ = const_cast< ::dmi::Uuid*>(
+      ::dmi::Uuid::internal_default_instance());
+}
+class UploadDebugInfoStatus::HasBitSetters {
+ public:
+  static const ::dmi::Uuid& device_uuid(const UploadDebugInfoStatus* msg);
+};
+
+const ::dmi::Uuid&
+UploadDebugInfoStatus::HasBitSetters::device_uuid(const UploadDebugInfoStatus* msg) {
+  return *msg->device_uuid_;
+}
+void UploadDebugInfoStatus::clear_device_uuid() {
+  if (GetArenaNoVirtual() == nullptr && device_uuid_ != nullptr) {
+    delete device_uuid_;
+  }
+  device_uuid_ = nullptr;
+}
+#if !defined(_MSC_VER) || _MSC_VER >= 1900
+const int UploadDebugInfoStatus::kDeviceUuidFieldNumber;
+const int UploadDebugInfoStatus::kStatusFieldNumber;
+const int UploadDebugInfoStatus::kPercentUploadedFieldNumber;
+const int UploadDebugInfoStatus::kReasonFieldNumber;
+const int UploadDebugInfoStatus::kLocationUrlFieldNumber;
+const int UploadDebugInfoStatus::kFileNameFieldNumber;
+#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900
+
+UploadDebugInfoStatus::UploadDebugInfoStatus()
+  : ::google::protobuf::Message(), _internal_metadata_(nullptr) {
+  SharedCtor();
+  // @@protoc_insertion_point(constructor:dmi.UploadDebugInfoStatus)
+}
+UploadDebugInfoStatus::UploadDebugInfoStatus(const UploadDebugInfoStatus& from)
+  : ::google::protobuf::Message(),
+      _internal_metadata_(nullptr) {
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  location_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.location_url().size() > 0) {
+    location_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.location_url_);
+  }
+  file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (from.file_name().size() > 0) {
+    file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
+  }
+  if (from.has_device_uuid()) {
+    device_uuid_ = new ::dmi::Uuid(*from.device_uuid_);
+  } else {
+    device_uuid_ = nullptr;
+  }
+  ::memcpy(&status_, &from.status_,
+    static_cast<size_t>(reinterpret_cast<char*>(&reason_) -
+    reinterpret_cast<char*>(&status_)) + sizeof(reason_));
+  // @@protoc_insertion_point(copy_constructor:dmi.UploadDebugInfoStatus)
+}
+
+void UploadDebugInfoStatus::SharedCtor() {
+  ::google::protobuf::internal::InitSCC(
+      &scc_info_UploadDebugInfoStatus_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
+  location_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  ::memset(&device_uuid_, 0, static_cast<size_t>(
+      reinterpret_cast<char*>(&reason_) -
+      reinterpret_cast<char*>(&device_uuid_)) + sizeof(reason_));
+}
+
+UploadDebugInfoStatus::~UploadDebugInfoStatus() {
+  // @@protoc_insertion_point(destructor:dmi.UploadDebugInfoStatus)
+  SharedDtor();
+}
+
+void UploadDebugInfoStatus::SharedDtor() {
+  location_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (this != internal_default_instance()) delete device_uuid_;
+}
+
+void UploadDebugInfoStatus::SetCachedSize(int size) const {
+  _cached_size_.Set(size);
+}
+const UploadDebugInfoStatus& UploadDebugInfoStatus::default_instance() {
+  ::google::protobuf::internal::InitSCC(&::scc_info_UploadDebugInfoStatus_dmi_2fsw_5fmanagement_5fservice_2eproto.base);
+  return *internal_default_instance();
+}
+
+
+void UploadDebugInfoStatus::Clear() {
+// @@protoc_insertion_point(message_clear_start:dmi.UploadDebugInfoStatus)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  // Prevent compiler warnings about cached_has_bits being unused
+  (void) cached_has_bits;
+
+  location_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+  if (GetArenaNoVirtual() == nullptr && device_uuid_ != nullptr) {
+    delete device_uuid_;
+  }
+  device_uuid_ = nullptr;
+  ::memset(&status_, 0, static_cast<size_t>(
+      reinterpret_cast<char*>(&reason_) -
+      reinterpret_cast<char*>(&status_)) + sizeof(reason_));
+  _internal_metadata_.Clear();
+}
+
+#if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+const char* UploadDebugInfoStatus::_InternalParse(const char* begin, const char* end, void* object,
+                  ::google::protobuf::internal::ParseContext* ctx) {
+  auto msg = static_cast<UploadDebugInfoStatus*>(object);
+  ::google::protobuf::int32 size; (void)size;
+  int depth; (void)depth;
+  ::google::protobuf::uint32 tag;
+  ::google::protobuf::internal::ParseFunc parser_till_end; (void)parser_till_end;
+  auto ptr = begin;
+  while (ptr < end) {
+    ptr = ::google::protobuf::io::Parse32(ptr, &tag);
+    GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+    switch (tag >> 3) {
+      // .dmi.Uuid device_uuid = 1;
+      case 1: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 10) goto handle_unusual;
+        ptr = ::google::protobuf::io::ReadSize(ptr, &size);
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        parser_till_end = ::dmi::Uuid::_InternalParse;
+        object = msg->mutable_device_uuid();
+        if (size > end - ptr) goto len_delim_till_end;
+        ptr += size;
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ctx->ParseExactRange(
+            {parser_till_end, object}, ptr - size, ptr));
+        break;
+      }
+      // .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+      case 2: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 16) goto handle_unusual;
+        ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+        msg->set_status(static_cast<::dmi::UploadDebugInfoStatus_UploadStatus>(val));
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        break;
+      }
+      // int32 percent_uploaded = 3;
+      case 3: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 24) goto handle_unusual;
+        msg->set_percent_uploaded(::google::protobuf::internal::ReadVarint(&ptr));
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        break;
+      }
+      // .dmi.UploadDebugInfoStatus.Reason reason = 4;
+      case 4: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 32) goto handle_unusual;
+        ::google::protobuf::uint64 val = ::google::protobuf::internal::ReadVarint(&ptr);
+        msg->set_reason(static_cast<::dmi::UploadDebugInfoStatus_Reason>(val));
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        break;
+      }
+      // string location_url = 5;
+      case 5: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 42) goto handle_unusual;
+        ptr = ::google::protobuf::io::ReadSize(ptr, &size);
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        ctx->extra_parse_data().SetFieldName("dmi.UploadDebugInfoStatus.location_url");
+        object = msg->mutable_location_url();
+        if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
+          parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
+          goto string_till_end;
+        }
+        GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
+        ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
+        ptr += size;
+        break;
+      }
+      // string file_name = 6;
+      case 6: {
+        if (static_cast<::google::protobuf::uint8>(tag) != 50) goto handle_unusual;
+        ptr = ::google::protobuf::io::ReadSize(ptr, &size);
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr);
+        ctx->extra_parse_data().SetFieldName("dmi.UploadDebugInfoStatus.file_name");
+        object = msg->mutable_file_name();
+        if (size > end - ptr + ::google::protobuf::internal::ParseContext::kSlopBytes) {
+          parser_till_end = ::google::protobuf::internal::GreedyStringParserUTF8;
+          goto string_till_end;
+        }
+        GOOGLE_PROTOBUF_PARSER_ASSERT(::google::protobuf::internal::StringCheckUTF8(ptr, size, ctx));
+        ::google::protobuf::internal::InlineGreedyStringParser(object, ptr, size, ctx);
+        ptr += size;
+        break;
+      }
+      default: {
+      handle_unusual:
+        if ((tag & 7) == 4 || tag == 0) {
+          ctx->EndGroup(tag);
+          return ptr;
+        }
+        auto res = UnknownFieldParse(tag, {_InternalParse, msg},
+          ptr, end, msg->_internal_metadata_.mutable_unknown_fields(), ctx);
+        ptr = res.first;
+        GOOGLE_PROTOBUF_PARSER_ASSERT(ptr != nullptr);
+        if (res.second) return ptr;
+      }
+    }  // switch
+  }  // while
+  return ptr;
+string_till_end:
+  static_cast<::std::string*>(object)->clear();
+  static_cast<::std::string*>(object)->reserve(size);
+  goto len_delim_till_end;
+len_delim_till_end:
+  return ctx->StoreAndTailCall(ptr, end, {_InternalParse, msg},
+                               {parser_till_end, object}, size);
+}
+#else  // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+bool UploadDebugInfoStatus::MergePartialFromCodedStream(
+    ::google::protobuf::io::CodedInputStream* input) {
+#define DO_(EXPRESSION) if (!PROTOBUF_PREDICT_TRUE(EXPRESSION)) goto failure
+  ::google::protobuf::uint32 tag;
+  // @@protoc_insertion_point(parse_start:dmi.UploadDebugInfoStatus)
+  for (;;) {
+    ::std::pair<::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
+    tag = p.first;
+    if (!p.second) goto handle_unusual;
+    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
+      // .dmi.Uuid device_uuid = 1;
+      case 1: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (10 & 0xFF)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
+               input, mutable_device_uuid()));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+      case 2: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (16 & 0xFF)) {
+          int value = 0;
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+                 input, &value)));
+          set_status(static_cast< ::dmi::UploadDebugInfoStatus_UploadStatus >(value));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // int32 percent_uploaded = 3;
+      case 3: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (24 & 0xFF)) {
+
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
+                 input, &percent_uploaded_)));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // .dmi.UploadDebugInfoStatus.Reason reason = 4;
+      case 4: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (32 & 0xFF)) {
+          int value = 0;
+          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
+                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(
+                 input, &value)));
+          set_reason(static_cast< ::dmi::UploadDebugInfoStatus_Reason >(value));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // string location_url = 5;
+      case 5: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (42 & 0xFF)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_location_url()));
+          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+            this->location_url().data(), static_cast<int>(this->location_url().length()),
+            ::google::protobuf::internal::WireFormatLite::PARSE,
+            "dmi.UploadDebugInfoStatus.location_url"));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      // string file_name = 6;
+      case 6: {
+        if (static_cast< ::google::protobuf::uint8>(tag) == (50 & 0xFF)) {
+          DO_(::google::protobuf::internal::WireFormatLite::ReadString(
+                input, this->mutable_file_name()));
+          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+            this->file_name().data(), static_cast<int>(this->file_name().length()),
+            ::google::protobuf::internal::WireFormatLite::PARSE,
+            "dmi.UploadDebugInfoStatus.file_name"));
+        } else {
+          goto handle_unusual;
+        }
+        break;
+      }
+
+      default: {
+      handle_unusual:
+        if (tag == 0) {
+          goto success;
+        }
+        DO_(::google::protobuf::internal::WireFormat::SkipField(
+              input, tag, _internal_metadata_.mutable_unknown_fields()));
+        break;
+      }
+    }
+  }
+success:
+  // @@protoc_insertion_point(parse_success:dmi.UploadDebugInfoStatus)
+  return true;
+failure:
+  // @@protoc_insertion_point(parse_failure:dmi.UploadDebugInfoStatus)
+  return false;
+#undef DO_
+}
+#endif  // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+
+void UploadDebugInfoStatus::SerializeWithCachedSizes(
+    ::google::protobuf::io::CodedOutputStream* output) const {
+  // @@protoc_insertion_point(serialize_start:dmi.UploadDebugInfoStatus)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  // .dmi.Uuid device_uuid = 1;
+  if (this->has_device_uuid()) {
+    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
+      1, HasBitSetters::device_uuid(this), output);
+  }
+
+  // .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+  if (this->status() != 0) {
+    ::google::protobuf::internal::WireFormatLite::WriteEnum(
+      2, this->status(), output);
+  }
+
+  // int32 percent_uploaded = 3;
+  if (this->percent_uploaded() != 0) {
+    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->percent_uploaded(), output);
+  }
+
+  // .dmi.UploadDebugInfoStatus.Reason reason = 4;
+  if (this->reason() != 0) {
+    ::google::protobuf::internal::WireFormatLite::WriteEnum(
+      4, this->reason(), output);
+  }
+
+  // string location_url = 5;
+  if (this->location_url().size() > 0) {
+    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+      this->location_url().data(), static_cast<int>(this->location_url().length()),
+      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
+      "dmi.UploadDebugInfoStatus.location_url");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      5, this->location_url(), output);
+  }
+
+  // string file_name = 6;
+  if (this->file_name().size() > 0) {
+    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+      this->file_name().data(), static_cast<int>(this->file_name().length()),
+      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
+      "dmi.UploadDebugInfoStatus.file_name");
+    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(
+      6, this->file_name(), output);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
+        _internal_metadata_.unknown_fields(), output);
+  }
+  // @@protoc_insertion_point(serialize_end:dmi.UploadDebugInfoStatus)
+}
+
+::google::protobuf::uint8* UploadDebugInfoStatus::InternalSerializeWithCachedSizesToArray(
+    ::google::protobuf::uint8* target) const {
+  // @@protoc_insertion_point(serialize_to_array_start:dmi.UploadDebugInfoStatus)
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  // .dmi.Uuid device_uuid = 1;
+  if (this->has_device_uuid()) {
+    target = ::google::protobuf::internal::WireFormatLite::
+      InternalWriteMessageToArray(
+        1, HasBitSetters::device_uuid(this), target);
+  }
+
+  // .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+  if (this->status() != 0) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+      2, this->status(), target);
+  }
+
+  // int32 percent_uploaded = 3;
+  if (this->percent_uploaded() != 0) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->percent_uploaded(), target);
+  }
+
+  // .dmi.UploadDebugInfoStatus.Reason reason = 4;
+  if (this->reason() != 0) {
+    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(
+      4, this->reason(), target);
+  }
+
+  // string location_url = 5;
+  if (this->location_url().size() > 0) {
+    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+      this->location_url().data(), static_cast<int>(this->location_url().length()),
+      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
+      "dmi.UploadDebugInfoStatus.location_url");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        5, this->location_url(), target);
+  }
+
+  // string file_name = 6;
+  if (this->file_name().size() > 0) {
+    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(
+      this->file_name().data(), static_cast<int>(this->file_name().length()),
+      ::google::protobuf::internal::WireFormatLite::SERIALIZE,
+      "dmi.UploadDebugInfoStatus.file_name");
+    target =
+      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(
+        6, this->file_name(), target);
+  }
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
+        _internal_metadata_.unknown_fields(), target);
+  }
+  // @@protoc_insertion_point(serialize_to_array_end:dmi.UploadDebugInfoStatus)
+  return target;
+}
+
+size_t UploadDebugInfoStatus::ByteSizeLong() const {
+// @@protoc_insertion_point(message_byte_size_start:dmi.UploadDebugInfoStatus)
+  size_t total_size = 0;
+
+  if (_internal_metadata_.have_unknown_fields()) {
+    total_size +=
+      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
+        _internal_metadata_.unknown_fields());
+  }
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  // Prevent compiler warnings about cached_has_bits being unused
+  (void) cached_has_bits;
+
+  // string location_url = 5;
+  if (this->location_url().size() > 0) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->location_url());
+  }
+
+  // string file_name = 6;
+  if (this->file_name().size() > 0) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::StringSize(
+        this->file_name());
+  }
+
+  // .dmi.Uuid device_uuid = 1;
+  if (this->has_device_uuid()) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::MessageSize(
+        *device_uuid_);
+  }
+
+  // .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+  if (this->status() != 0) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::EnumSize(this->status());
+  }
+
+  // int32 percent_uploaded = 3;
+  if (this->percent_uploaded() != 0) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::Int32Size(
+        this->percent_uploaded());
+  }
+
+  // .dmi.UploadDebugInfoStatus.Reason reason = 4;
+  if (this->reason() != 0) {
+    total_size += 1 +
+      ::google::protobuf::internal::WireFormatLite::EnumSize(this->reason());
+  }
+
+  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
+  SetCachedSize(cached_size);
+  return total_size;
+}
+
+void UploadDebugInfoStatus::MergeFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_merge_from_start:dmi.UploadDebugInfoStatus)
+  GOOGLE_DCHECK_NE(&from, this);
+  const UploadDebugInfoStatus* source =
+      ::google::protobuf::DynamicCastToGenerated<UploadDebugInfoStatus>(
+          &from);
+  if (source == nullptr) {
+  // @@protoc_insertion_point(generalized_merge_from_cast_fail:dmi.UploadDebugInfoStatus)
+    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
+  } else {
+  // @@protoc_insertion_point(generalized_merge_from_cast_success:dmi.UploadDebugInfoStatus)
+    MergeFrom(*source);
+  }
+}
+
+void UploadDebugInfoStatus::MergeFrom(const UploadDebugInfoStatus& from) {
+// @@protoc_insertion_point(class_specific_merge_from_start:dmi.UploadDebugInfoStatus)
+  GOOGLE_DCHECK_NE(&from, this);
+  _internal_metadata_.MergeFrom(from._internal_metadata_);
+  ::google::protobuf::uint32 cached_has_bits = 0;
+  (void) cached_has_bits;
+
+  if (from.location_url().size() > 0) {
+
+    location_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.location_url_);
+  }
+  if (from.file_name().size() > 0) {
+
+    file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);
+  }
+  if (from.has_device_uuid()) {
+    mutable_device_uuid()->::dmi::Uuid::MergeFrom(from.device_uuid());
+  }
+  if (from.status() != 0) {
+    set_status(from.status());
+  }
+  if (from.percent_uploaded() != 0) {
+    set_percent_uploaded(from.percent_uploaded());
+  }
+  if (from.reason() != 0) {
+    set_reason(from.reason());
+  }
+}
+
+void UploadDebugInfoStatus::CopyFrom(const ::google::protobuf::Message& from) {
+// @@protoc_insertion_point(generalized_copy_from_start:dmi.UploadDebugInfoStatus)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+void UploadDebugInfoStatus::CopyFrom(const UploadDebugInfoStatus& from) {
+// @@protoc_insertion_point(class_specific_copy_from_start:dmi.UploadDebugInfoStatus)
+  if (&from == this) return;
+  Clear();
+  MergeFrom(from);
+}
+
+bool UploadDebugInfoStatus::IsInitialized() const {
+  return true;
+}
+
+void UploadDebugInfoStatus::Swap(UploadDebugInfoStatus* other) {
+  if (other == this) return;
+  InternalSwap(other);
+}
+void UploadDebugInfoStatus::InternalSwap(UploadDebugInfoStatus* other) {
+  using std::swap;
+  _internal_metadata_.Swap(&other->_internal_metadata_);
+  location_url_.Swap(&other->location_url_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+    GetArenaNoVirtual());
+  file_name_.Swap(&other->file_name_, &::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+    GetArenaNoVirtual());
+  swap(device_uuid_, other->device_uuid_);
+  swap(status_, other->status_);
+  swap(percent_uploaded_, other->percent_uploaded_);
+  swap(reason_, other->reason_);
+}
+
+::google::protobuf::Metadata UploadDebugInfoStatus::GetMetadata() const {
+  ::google::protobuf::internal::AssignDescriptors(&::assign_descriptors_table_dmi_2fsw_5fmanagement_5fservice_2eproto);
+  return ::file_level_metadata_dmi_2fsw_5fmanagement_5fservice_2eproto[kIndexInFileMessages];
+}
+
+
 // @@protoc_insertion_point(namespace_scope)
 }  // namespace dmi
 namespace google {
@@ -3200,6 +4288,12 @@
 template<> PROTOBUF_NOINLINE ::dmi::StartupConfigInfoResponse* Arena::CreateMaybeMessage< ::dmi::StartupConfigInfoResponse >(Arena* arena) {
   return Arena::CreateInternal< ::dmi::StartupConfigInfoResponse >(arena);
 }
+template<> PROTOBUF_NOINLINE ::dmi::UploadDebugInfoRequest* Arena::CreateMaybeMessage< ::dmi::UploadDebugInfoRequest >(Arena* arena) {
+  return Arena::CreateInternal< ::dmi::UploadDebugInfoRequest >(arena);
+}
+template<> PROTOBUF_NOINLINE ::dmi::UploadDebugInfoStatus* Arena::CreateMaybeMessage< ::dmi::UploadDebugInfoStatus >(Arena* arena) {
+  return Arena::CreateInternal< ::dmi::UploadDebugInfoStatus >(arena);
+}
 }  // namespace protobuf
 }  // namespace google
 
diff --git a/cpp/dmi/sw_management_service.pb.h b/cpp/dmi/sw_management_service.pb.h
index 2610c1a..82b897a 100644
--- a/cpp/dmi/sw_management_service.pb.h
+++ b/cpp/dmi/sw_management_service.pb.h
@@ -45,7 +45,7 @@
     PROTOBUF_SECTION_VARIABLE(protodesc_cold);
   static const ::google::protobuf::internal::AuxillaryParseTableField aux[]
     PROTOBUF_SECTION_VARIABLE(protodesc_cold);
-  static const ::google::protobuf::internal::ParseTable schema[7]
+  static const ::google::protobuf::internal::ParseTable schema[9]
     PROTOBUF_SECTION_VARIABLE(protodesc_cold);
   static const ::google::protobuf::internal::FieldMetadata field_metadata[];
   static const ::google::protobuf::internal::SerializationTable serialization_table[];
@@ -74,6 +74,12 @@
 class StartupConfigInfoResponse;
 class StartupConfigInfoResponseDefaultTypeInternal;
 extern StartupConfigInfoResponseDefaultTypeInternal _StartupConfigInfoResponse_default_instance_;
+class UploadDebugInfoRequest;
+class UploadDebugInfoRequestDefaultTypeInternal;
+extern UploadDebugInfoRequestDefaultTypeInternal _UploadDebugInfoRequest_default_instance_;
+class UploadDebugInfoStatus;
+class UploadDebugInfoStatusDefaultTypeInternal;
+extern UploadDebugInfoStatusDefaultTypeInternal _UploadDebugInfoStatus_default_instance_;
 }  // namespace dmi
 namespace google {
 namespace protobuf {
@@ -84,6 +90,8 @@
 template<> ::dmi::SoftwareVersionInformation* Arena::CreateMaybeMessage<::dmi::SoftwareVersionInformation>(Arena*);
 template<> ::dmi::StartupConfigInfoRequest* Arena::CreateMaybeMessage<::dmi::StartupConfigInfoRequest>(Arena*);
 template<> ::dmi::StartupConfigInfoResponse* Arena::CreateMaybeMessage<::dmi::StartupConfigInfoResponse>(Arena*);
+template<> ::dmi::UploadDebugInfoRequest* Arena::CreateMaybeMessage<::dmi::UploadDebugInfoRequest>(Arena*);
+template<> ::dmi::UploadDebugInfoStatus* Arena::CreateMaybeMessage<::dmi::UploadDebugInfoStatus>(Arena*);
 }  // namespace protobuf
 }  // namespace google
 namespace dmi {
@@ -160,6 +168,55 @@
   return ::google::protobuf::internal::ParseNamedEnum<StartupConfigInfoResponse_Reason>(
     StartupConfigInfoResponse_Reason_descriptor(), name, value);
 }
+enum UploadDebugInfoStatus_UploadStatus {
+  UploadDebugInfoStatus_UploadStatus_UNDEFINED_UPLOAD_STATUS = 0,
+  UploadDebugInfoStatus_UploadStatus_COMPLETE = 1,
+  UploadDebugInfoStatus_UploadStatus_IN_PROGRESS = 2,
+  UploadDebugInfoStatus_UploadStatus_ERROR = 3,
+  UploadDebugInfoStatus_UploadStatus_UploadDebugInfoStatus_UploadStatus_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
+  UploadDebugInfoStatus_UploadStatus_UploadDebugInfoStatus_UploadStatus_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
+};
+bool UploadDebugInfoStatus_UploadStatus_IsValid(int value);
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus_UploadStatus_UploadStatus_MIN = UploadDebugInfoStatus_UploadStatus_UNDEFINED_UPLOAD_STATUS;
+const UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus_UploadStatus_UploadStatus_MAX = UploadDebugInfoStatus_UploadStatus_ERROR;
+const int UploadDebugInfoStatus_UploadStatus_UploadStatus_ARRAYSIZE = UploadDebugInfoStatus_UploadStatus_UploadStatus_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* UploadDebugInfoStatus_UploadStatus_descriptor();
+inline const ::std::string& UploadDebugInfoStatus_UploadStatus_Name(UploadDebugInfoStatus_UploadStatus value) {
+  return ::google::protobuf::internal::NameOfEnum(
+    UploadDebugInfoStatus_UploadStatus_descriptor(), value);
+}
+inline bool UploadDebugInfoStatus_UploadStatus_Parse(
+    const ::std::string& name, UploadDebugInfoStatus_UploadStatus* value) {
+  return ::google::protobuf::internal::ParseNamedEnum<UploadDebugInfoStatus_UploadStatus>(
+    UploadDebugInfoStatus_UploadStatus_descriptor(), name, value);
+}
+enum UploadDebugInfoStatus_Reason {
+  UploadDebugInfoStatus_Reason_UNDEFINED_REASON = 0,
+  UploadDebugInfoStatus_Reason_UNKNOWN_DEVICE = 1,
+  UploadDebugInfoStatus_Reason_INTERNAL_ERROR = 2,
+  UploadDebugInfoStatus_Reason_DEVICE_UNREACHABLE = 3,
+  UploadDebugInfoStatus_Reason_REMOTE_LOCATION_UNREACHABLE = 4,
+  UploadDebugInfoStatus_Reason_REMOTE_LOCATION_PERMISSION_DENIED = 5,
+  UploadDebugInfoStatus_Reason_ERROR_DURING_UPLOAD = 6,
+  UploadDebugInfoStatus_Reason_UploadDebugInfoStatus_Reason_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::min(),
+  UploadDebugInfoStatus_Reason_UploadDebugInfoStatus_Reason_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<::google::protobuf::int32>::max()
+};
+bool UploadDebugInfoStatus_Reason_IsValid(int value);
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus_Reason_Reason_MIN = UploadDebugInfoStatus_Reason_UNDEFINED_REASON;
+const UploadDebugInfoStatus_Reason UploadDebugInfoStatus_Reason_Reason_MAX = UploadDebugInfoStatus_Reason_ERROR_DURING_UPLOAD;
+const int UploadDebugInfoStatus_Reason_Reason_ARRAYSIZE = UploadDebugInfoStatus_Reason_Reason_MAX + 1;
+
+const ::google::protobuf::EnumDescriptor* UploadDebugInfoStatus_Reason_descriptor();
+inline const ::std::string& UploadDebugInfoStatus_Reason_Name(UploadDebugInfoStatus_Reason value) {
+  return ::google::protobuf::internal::NameOfEnum(
+    UploadDebugInfoStatus_Reason_descriptor(), value);
+}
+inline bool UploadDebugInfoStatus_Reason_Parse(
+    const ::std::string& name, UploadDebugInfoStatus_Reason* value) {
+  return ::google::protobuf::internal::ParseNamedEnum<UploadDebugInfoStatus_Reason>(
+    UploadDebugInfoStatus_Reason_descriptor(), name, value);
+}
 // ===================================================================
 
 class SoftwareVersionInformation final :
@@ -1199,6 +1256,368 @@
   mutable ::google::protobuf::internal::CachedSize _cached_size_;
   friend struct ::TableStruct_dmi_2fsw_5fmanagement_5fservice_2eproto;
 };
+// -------------------------------------------------------------------
+
+class UploadDebugInfoRequest final :
+    public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:dmi.UploadDebugInfoRequest) */ {
+ public:
+  UploadDebugInfoRequest();
+  virtual ~UploadDebugInfoRequest();
+
+  UploadDebugInfoRequest(const UploadDebugInfoRequest& from);
+
+  inline UploadDebugInfoRequest& operator=(const UploadDebugInfoRequest& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  UploadDebugInfoRequest(UploadDebugInfoRequest&& from) noexcept
+    : UploadDebugInfoRequest() {
+    *this = ::std::move(from);
+  }
+
+  inline UploadDebugInfoRequest& operator=(UploadDebugInfoRequest&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  static const ::google::protobuf::Descriptor* descriptor() {
+    return default_instance().GetDescriptor();
+  }
+  static const UploadDebugInfoRequest& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const UploadDebugInfoRequest* internal_default_instance() {
+    return reinterpret_cast<const UploadDebugInfoRequest*>(
+               &_UploadDebugInfoRequest_default_instance_);
+  }
+  static constexpr int kIndexInFileMessages =
+    7;
+
+  void Swap(UploadDebugInfoRequest* other);
+  friend void swap(UploadDebugInfoRequest& a, UploadDebugInfoRequest& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline UploadDebugInfoRequest* New() const final {
+    return CreateMaybeMessage<UploadDebugInfoRequest>(nullptr);
+  }
+
+  UploadDebugInfoRequest* New(::google::protobuf::Arena* arena) const final {
+    return CreateMaybeMessage<UploadDebugInfoRequest>(arena);
+  }
+  void CopyFrom(const ::google::protobuf::Message& from) final;
+  void MergeFrom(const ::google::protobuf::Message& from) final;
+  void CopyFrom(const UploadDebugInfoRequest& from);
+  void MergeFrom(const UploadDebugInfoRequest& from);
+  PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
+  bool IsInitialized() const final;
+
+  size_t ByteSizeLong() const final;
+  #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+  static const char* _InternalParse(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx);
+  ::google::protobuf::internal::ParseFunc _ParseFunc() const final { return _InternalParse; }
+  #else
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) final;
+  #endif  // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const final;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      ::google::protobuf::uint8* target) const final;
+  int GetCachedSize() const final { return _cached_size_.Get(); }
+
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const final;
+  void InternalSwap(UploadDebugInfoRequest* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return nullptr;
+  }
+  inline void* MaybeArenaPtr() const {
+    return nullptr;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const final;
+
+  // nested types ----------------------------------------------------
+
+  // accessors -------------------------------------------------------
+
+  // string location_url = 3;
+  void clear_location_url();
+  static const int kLocationUrlFieldNumber = 3;
+  const ::std::string& location_url() const;
+  void set_location_url(const ::std::string& value);
+  #if LANG_CXX11
+  void set_location_url(::std::string&& value);
+  #endif
+  void set_location_url(const char* value);
+  void set_location_url(const char* value, size_t size);
+  ::std::string* mutable_location_url();
+  ::std::string* release_location_url();
+  void set_allocated_location_url(::std::string* location_url);
+
+  // .dmi.Uuid device_uuid = 1;
+  bool has_device_uuid() const;
+  void clear_device_uuid();
+  static const int kDeviceUuidFieldNumber = 1;
+  const ::dmi::Uuid& device_uuid() const;
+  ::dmi::Uuid* release_device_uuid();
+  ::dmi::Uuid* mutable_device_uuid();
+  void set_allocated_device_uuid(::dmi::Uuid* device_uuid);
+
+  // @@protoc_insertion_point(class_scope:dmi.UploadDebugInfoRequest)
+ private:
+  class HasBitSetters;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::ArenaStringPtr location_url_;
+  ::dmi::Uuid* device_uuid_;
+  mutable ::google::protobuf::internal::CachedSize _cached_size_;
+  friend struct ::TableStruct_dmi_2fsw_5fmanagement_5fservice_2eproto;
+};
+// -------------------------------------------------------------------
+
+class UploadDebugInfoStatus final :
+    public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:dmi.UploadDebugInfoStatus) */ {
+ public:
+  UploadDebugInfoStatus();
+  virtual ~UploadDebugInfoStatus();
+
+  UploadDebugInfoStatus(const UploadDebugInfoStatus& from);
+
+  inline UploadDebugInfoStatus& operator=(const UploadDebugInfoStatus& from) {
+    CopyFrom(from);
+    return *this;
+  }
+  #if LANG_CXX11
+  UploadDebugInfoStatus(UploadDebugInfoStatus&& from) noexcept
+    : UploadDebugInfoStatus() {
+    *this = ::std::move(from);
+  }
+
+  inline UploadDebugInfoStatus& operator=(UploadDebugInfoStatus&& from) noexcept {
+    if (GetArenaNoVirtual() == from.GetArenaNoVirtual()) {
+      if (this != &from) InternalSwap(&from);
+    } else {
+      CopyFrom(from);
+    }
+    return *this;
+  }
+  #endif
+  static const ::google::protobuf::Descriptor* descriptor() {
+    return default_instance().GetDescriptor();
+  }
+  static const UploadDebugInfoStatus& default_instance();
+
+  static void InitAsDefaultInstance();  // FOR INTERNAL USE ONLY
+  static inline const UploadDebugInfoStatus* internal_default_instance() {
+    return reinterpret_cast<const UploadDebugInfoStatus*>(
+               &_UploadDebugInfoStatus_default_instance_);
+  }
+  static constexpr int kIndexInFileMessages =
+    8;
+
+  void Swap(UploadDebugInfoStatus* other);
+  friend void swap(UploadDebugInfoStatus& a, UploadDebugInfoStatus& b) {
+    a.Swap(&b);
+  }
+
+  // implements Message ----------------------------------------------
+
+  inline UploadDebugInfoStatus* New() const final {
+    return CreateMaybeMessage<UploadDebugInfoStatus>(nullptr);
+  }
+
+  UploadDebugInfoStatus* New(::google::protobuf::Arena* arena) const final {
+    return CreateMaybeMessage<UploadDebugInfoStatus>(arena);
+  }
+  void CopyFrom(const ::google::protobuf::Message& from) final;
+  void MergeFrom(const ::google::protobuf::Message& from) final;
+  void CopyFrom(const UploadDebugInfoStatus& from);
+  void MergeFrom(const UploadDebugInfoStatus& from);
+  PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
+  bool IsInitialized() const final;
+
+  size_t ByteSizeLong() const final;
+  #if GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+  static const char* _InternalParse(const char* begin, const char* end, void* object, ::google::protobuf::internal::ParseContext* ctx);
+  ::google::protobuf::internal::ParseFunc _ParseFunc() const final { return _InternalParse; }
+  #else
+  bool MergePartialFromCodedStream(
+      ::google::protobuf::io::CodedInputStream* input) final;
+  #endif  // GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
+  void SerializeWithCachedSizes(
+      ::google::protobuf::io::CodedOutputStream* output) const final;
+  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(
+      ::google::protobuf::uint8* target) const final;
+  int GetCachedSize() const final { return _cached_size_.Get(); }
+
+  private:
+  void SharedCtor();
+  void SharedDtor();
+  void SetCachedSize(int size) const final;
+  void InternalSwap(UploadDebugInfoStatus* other);
+  private:
+  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {
+    return nullptr;
+  }
+  inline void* MaybeArenaPtr() const {
+    return nullptr;
+  }
+  public:
+
+  ::google::protobuf::Metadata GetMetadata() const final;
+
+  // nested types ----------------------------------------------------
+
+  typedef UploadDebugInfoStatus_UploadStatus UploadStatus;
+  static const UploadStatus UNDEFINED_UPLOAD_STATUS =
+    UploadDebugInfoStatus_UploadStatus_UNDEFINED_UPLOAD_STATUS;
+  static const UploadStatus COMPLETE =
+    UploadDebugInfoStatus_UploadStatus_COMPLETE;
+  static const UploadStatus IN_PROGRESS =
+    UploadDebugInfoStatus_UploadStatus_IN_PROGRESS;
+  static const UploadStatus ERROR =
+    UploadDebugInfoStatus_UploadStatus_ERROR;
+  static inline bool UploadStatus_IsValid(int value) {
+    return UploadDebugInfoStatus_UploadStatus_IsValid(value);
+  }
+  static const UploadStatus UploadStatus_MIN =
+    UploadDebugInfoStatus_UploadStatus_UploadStatus_MIN;
+  static const UploadStatus UploadStatus_MAX =
+    UploadDebugInfoStatus_UploadStatus_UploadStatus_MAX;
+  static const int UploadStatus_ARRAYSIZE =
+    UploadDebugInfoStatus_UploadStatus_UploadStatus_ARRAYSIZE;
+  static inline const ::google::protobuf::EnumDescriptor*
+  UploadStatus_descriptor() {
+    return UploadDebugInfoStatus_UploadStatus_descriptor();
+  }
+  static inline const ::std::string& UploadStatus_Name(UploadStatus value) {
+    return UploadDebugInfoStatus_UploadStatus_Name(value);
+  }
+  static inline bool UploadStatus_Parse(const ::std::string& name,
+      UploadStatus* value) {
+    return UploadDebugInfoStatus_UploadStatus_Parse(name, value);
+  }
+
+  typedef UploadDebugInfoStatus_Reason Reason;
+  static const Reason UNDEFINED_REASON =
+    UploadDebugInfoStatus_Reason_UNDEFINED_REASON;
+  static const Reason UNKNOWN_DEVICE =
+    UploadDebugInfoStatus_Reason_UNKNOWN_DEVICE;
+  static const Reason INTERNAL_ERROR =
+    UploadDebugInfoStatus_Reason_INTERNAL_ERROR;
+  static const Reason DEVICE_UNREACHABLE =
+    UploadDebugInfoStatus_Reason_DEVICE_UNREACHABLE;
+  static const Reason REMOTE_LOCATION_UNREACHABLE =
+    UploadDebugInfoStatus_Reason_REMOTE_LOCATION_UNREACHABLE;
+  static const Reason REMOTE_LOCATION_PERMISSION_DENIED =
+    UploadDebugInfoStatus_Reason_REMOTE_LOCATION_PERMISSION_DENIED;
+  static const Reason ERROR_DURING_UPLOAD =
+    UploadDebugInfoStatus_Reason_ERROR_DURING_UPLOAD;
+  static inline bool Reason_IsValid(int value) {
+    return UploadDebugInfoStatus_Reason_IsValid(value);
+  }
+  static const Reason Reason_MIN =
+    UploadDebugInfoStatus_Reason_Reason_MIN;
+  static const Reason Reason_MAX =
+    UploadDebugInfoStatus_Reason_Reason_MAX;
+  static const int Reason_ARRAYSIZE =
+    UploadDebugInfoStatus_Reason_Reason_ARRAYSIZE;
+  static inline const ::google::protobuf::EnumDescriptor*
+  Reason_descriptor() {
+    return UploadDebugInfoStatus_Reason_descriptor();
+  }
+  static inline const ::std::string& Reason_Name(Reason value) {
+    return UploadDebugInfoStatus_Reason_Name(value);
+  }
+  static inline bool Reason_Parse(const ::std::string& name,
+      Reason* value) {
+    return UploadDebugInfoStatus_Reason_Parse(name, value);
+  }
+
+  // accessors -------------------------------------------------------
+
+  // string location_url = 5;
+  void clear_location_url();
+  static const int kLocationUrlFieldNumber = 5;
+  const ::std::string& location_url() const;
+  void set_location_url(const ::std::string& value);
+  #if LANG_CXX11
+  void set_location_url(::std::string&& value);
+  #endif
+  void set_location_url(const char* value);
+  void set_location_url(const char* value, size_t size);
+  ::std::string* mutable_location_url();
+  ::std::string* release_location_url();
+  void set_allocated_location_url(::std::string* location_url);
+
+  // string file_name = 6;
+  void clear_file_name();
+  static const int kFileNameFieldNumber = 6;
+  const ::std::string& file_name() const;
+  void set_file_name(const ::std::string& value);
+  #if LANG_CXX11
+  void set_file_name(::std::string&& value);
+  #endif
+  void set_file_name(const char* value);
+  void set_file_name(const char* value, size_t size);
+  ::std::string* mutable_file_name();
+  ::std::string* release_file_name();
+  void set_allocated_file_name(::std::string* file_name);
+
+  // .dmi.Uuid device_uuid = 1;
+  bool has_device_uuid() const;
+  void clear_device_uuid();
+  static const int kDeviceUuidFieldNumber = 1;
+  const ::dmi::Uuid& device_uuid() const;
+  ::dmi::Uuid* release_device_uuid();
+  ::dmi::Uuid* mutable_device_uuid();
+  void set_allocated_device_uuid(::dmi::Uuid* device_uuid);
+
+  // .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+  void clear_status();
+  static const int kStatusFieldNumber = 2;
+  ::dmi::UploadDebugInfoStatus_UploadStatus status() const;
+  void set_status(::dmi::UploadDebugInfoStatus_UploadStatus value);
+
+  // int32 percent_uploaded = 3;
+  void clear_percent_uploaded();
+  static const int kPercentUploadedFieldNumber = 3;
+  ::google::protobuf::int32 percent_uploaded() const;
+  void set_percent_uploaded(::google::protobuf::int32 value);
+
+  // .dmi.UploadDebugInfoStatus.Reason reason = 4;
+  void clear_reason();
+  static const int kReasonFieldNumber = 4;
+  ::dmi::UploadDebugInfoStatus_Reason reason() const;
+  void set_reason(::dmi::UploadDebugInfoStatus_Reason value);
+
+  // @@protoc_insertion_point(class_scope:dmi.UploadDebugInfoStatus)
+ private:
+  class HasBitSetters;
+
+  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
+  ::google::protobuf::internal::ArenaStringPtr location_url_;
+  ::google::protobuf::internal::ArenaStringPtr file_name_;
+  ::dmi::Uuid* device_uuid_;
+  int status_;
+  ::google::protobuf::int32 percent_uploaded_;
+  int reason_;
+  mutable ::google::protobuf::internal::CachedSize _cached_size_;
+  friend struct ::TableStruct_dmi_2fsw_5fmanagement_5fservice_2eproto;
+};
 // ===================================================================
 
 
@@ -1921,6 +2340,305 @@
   // @@protoc_insertion_point(field_set_allocated:dmi.StartupConfigInfoResponse.reason_detail)
 }
 
+// -------------------------------------------------------------------
+
+// UploadDebugInfoRequest
+
+// .dmi.Uuid device_uuid = 1;
+inline bool UploadDebugInfoRequest::has_device_uuid() const {
+  return this != internal_default_instance() && device_uuid_ != nullptr;
+}
+inline const ::dmi::Uuid& UploadDebugInfoRequest::device_uuid() const {
+  const ::dmi::Uuid* p = device_uuid_;
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoRequest.device_uuid)
+  return p != nullptr ? *p : *reinterpret_cast<const ::dmi::Uuid*>(
+      &::dmi::_Uuid_default_instance_);
+}
+inline ::dmi::Uuid* UploadDebugInfoRequest::release_device_uuid() {
+  // @@protoc_insertion_point(field_release:dmi.UploadDebugInfoRequest.device_uuid)
+  
+  ::dmi::Uuid* temp = device_uuid_;
+  device_uuid_ = nullptr;
+  return temp;
+}
+inline ::dmi::Uuid* UploadDebugInfoRequest::mutable_device_uuid() {
+  
+  if (device_uuid_ == nullptr) {
+    auto* p = CreateMaybeMessage<::dmi::Uuid>(GetArenaNoVirtual());
+    device_uuid_ = p;
+  }
+  // @@protoc_insertion_point(field_mutable:dmi.UploadDebugInfoRequest.device_uuid)
+  return device_uuid_;
+}
+inline void UploadDebugInfoRequest::set_allocated_device_uuid(::dmi::Uuid* device_uuid) {
+  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
+  if (message_arena == nullptr) {
+    delete reinterpret_cast< ::google::protobuf::MessageLite*>(device_uuid_);
+  }
+  if (device_uuid) {
+    ::google::protobuf::Arena* submessage_arena = nullptr;
+    if (message_arena != submessage_arena) {
+      device_uuid = ::google::protobuf::internal::GetOwnedMessage(
+          message_arena, device_uuid, submessage_arena);
+    }
+    
+  } else {
+    
+  }
+  device_uuid_ = device_uuid;
+  // @@protoc_insertion_point(field_set_allocated:dmi.UploadDebugInfoRequest.device_uuid)
+}
+
+// string location_url = 3;
+inline void UploadDebugInfoRequest::clear_location_url() {
+  location_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline const ::std::string& UploadDebugInfoRequest::location_url() const {
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoRequest.location_url)
+  return location_url_.GetNoArena();
+}
+inline void UploadDebugInfoRequest::set_location_url(const ::std::string& value) {
+  
+  location_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:dmi.UploadDebugInfoRequest.location_url)
+}
+#if LANG_CXX11
+inline void UploadDebugInfoRequest::set_location_url(::std::string&& value) {
+  
+  location_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:dmi.UploadDebugInfoRequest.location_url)
+}
+#endif
+inline void UploadDebugInfoRequest::set_location_url(const char* value) {
+  GOOGLE_DCHECK(value != nullptr);
+  
+  location_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:dmi.UploadDebugInfoRequest.location_url)
+}
+inline void UploadDebugInfoRequest::set_location_url(const char* value, size_t size) {
+  
+  location_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:dmi.UploadDebugInfoRequest.location_url)
+}
+inline ::std::string* UploadDebugInfoRequest::mutable_location_url() {
+  
+  // @@protoc_insertion_point(field_mutable:dmi.UploadDebugInfoRequest.location_url)
+  return location_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* UploadDebugInfoRequest::release_location_url() {
+  // @@protoc_insertion_point(field_release:dmi.UploadDebugInfoRequest.location_url)
+  
+  return location_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void UploadDebugInfoRequest::set_allocated_location_url(::std::string* location_url) {
+  if (location_url != nullptr) {
+    
+  } else {
+    
+  }
+  location_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), location_url);
+  // @@protoc_insertion_point(field_set_allocated:dmi.UploadDebugInfoRequest.location_url)
+}
+
+// -------------------------------------------------------------------
+
+// UploadDebugInfoStatus
+
+// .dmi.Uuid device_uuid = 1;
+inline bool UploadDebugInfoStatus::has_device_uuid() const {
+  return this != internal_default_instance() && device_uuid_ != nullptr;
+}
+inline const ::dmi::Uuid& UploadDebugInfoStatus::device_uuid() const {
+  const ::dmi::Uuid* p = device_uuid_;
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoStatus.device_uuid)
+  return p != nullptr ? *p : *reinterpret_cast<const ::dmi::Uuid*>(
+      &::dmi::_Uuid_default_instance_);
+}
+inline ::dmi::Uuid* UploadDebugInfoStatus::release_device_uuid() {
+  // @@protoc_insertion_point(field_release:dmi.UploadDebugInfoStatus.device_uuid)
+  
+  ::dmi::Uuid* temp = device_uuid_;
+  device_uuid_ = nullptr;
+  return temp;
+}
+inline ::dmi::Uuid* UploadDebugInfoStatus::mutable_device_uuid() {
+  
+  if (device_uuid_ == nullptr) {
+    auto* p = CreateMaybeMessage<::dmi::Uuid>(GetArenaNoVirtual());
+    device_uuid_ = p;
+  }
+  // @@protoc_insertion_point(field_mutable:dmi.UploadDebugInfoStatus.device_uuid)
+  return device_uuid_;
+}
+inline void UploadDebugInfoStatus::set_allocated_device_uuid(::dmi::Uuid* device_uuid) {
+  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();
+  if (message_arena == nullptr) {
+    delete reinterpret_cast< ::google::protobuf::MessageLite*>(device_uuid_);
+  }
+  if (device_uuid) {
+    ::google::protobuf::Arena* submessage_arena = nullptr;
+    if (message_arena != submessage_arena) {
+      device_uuid = ::google::protobuf::internal::GetOwnedMessage(
+          message_arena, device_uuid, submessage_arena);
+    }
+    
+  } else {
+    
+  }
+  device_uuid_ = device_uuid;
+  // @@protoc_insertion_point(field_set_allocated:dmi.UploadDebugInfoStatus.device_uuid)
+}
+
+// .dmi.UploadDebugInfoStatus.UploadStatus status = 2;
+inline void UploadDebugInfoStatus::clear_status() {
+  status_ = 0;
+}
+inline ::dmi::UploadDebugInfoStatus_UploadStatus UploadDebugInfoStatus::status() const {
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoStatus.status)
+  return static_cast< ::dmi::UploadDebugInfoStatus_UploadStatus >(status_);
+}
+inline void UploadDebugInfoStatus::set_status(::dmi::UploadDebugInfoStatus_UploadStatus value) {
+  
+  status_ = value;
+  // @@protoc_insertion_point(field_set:dmi.UploadDebugInfoStatus.status)
+}
+
+// int32 percent_uploaded = 3;
+inline void UploadDebugInfoStatus::clear_percent_uploaded() {
+  percent_uploaded_ = 0;
+}
+inline ::google::protobuf::int32 UploadDebugInfoStatus::percent_uploaded() const {
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoStatus.percent_uploaded)
+  return percent_uploaded_;
+}
+inline void UploadDebugInfoStatus::set_percent_uploaded(::google::protobuf::int32 value) {
+  
+  percent_uploaded_ = value;
+  // @@protoc_insertion_point(field_set:dmi.UploadDebugInfoStatus.percent_uploaded)
+}
+
+// .dmi.UploadDebugInfoStatus.Reason reason = 4;
+inline void UploadDebugInfoStatus::clear_reason() {
+  reason_ = 0;
+}
+inline ::dmi::UploadDebugInfoStatus_Reason UploadDebugInfoStatus::reason() const {
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoStatus.reason)
+  return static_cast< ::dmi::UploadDebugInfoStatus_Reason >(reason_);
+}
+inline void UploadDebugInfoStatus::set_reason(::dmi::UploadDebugInfoStatus_Reason value) {
+  
+  reason_ = value;
+  // @@protoc_insertion_point(field_set:dmi.UploadDebugInfoStatus.reason)
+}
+
+// string location_url = 5;
+inline void UploadDebugInfoStatus::clear_location_url() {
+  location_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline const ::std::string& UploadDebugInfoStatus::location_url() const {
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoStatus.location_url)
+  return location_url_.GetNoArena();
+}
+inline void UploadDebugInfoStatus::set_location_url(const ::std::string& value) {
+  
+  location_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:dmi.UploadDebugInfoStatus.location_url)
+}
+#if LANG_CXX11
+inline void UploadDebugInfoStatus::set_location_url(::std::string&& value) {
+  
+  location_url_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:dmi.UploadDebugInfoStatus.location_url)
+}
+#endif
+inline void UploadDebugInfoStatus::set_location_url(const char* value) {
+  GOOGLE_DCHECK(value != nullptr);
+  
+  location_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:dmi.UploadDebugInfoStatus.location_url)
+}
+inline void UploadDebugInfoStatus::set_location_url(const char* value, size_t size) {
+  
+  location_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:dmi.UploadDebugInfoStatus.location_url)
+}
+inline ::std::string* UploadDebugInfoStatus::mutable_location_url() {
+  
+  // @@protoc_insertion_point(field_mutable:dmi.UploadDebugInfoStatus.location_url)
+  return location_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* UploadDebugInfoStatus::release_location_url() {
+  // @@protoc_insertion_point(field_release:dmi.UploadDebugInfoStatus.location_url)
+  
+  return location_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void UploadDebugInfoStatus::set_allocated_location_url(::std::string* location_url) {
+  if (location_url != nullptr) {
+    
+  } else {
+    
+  }
+  location_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), location_url);
+  // @@protoc_insertion_point(field_set_allocated:dmi.UploadDebugInfoStatus.location_url)
+}
+
+// string file_name = 6;
+inline void UploadDebugInfoStatus::clear_file_name() {
+  file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline const ::std::string& UploadDebugInfoStatus::file_name() const {
+  // @@protoc_insertion_point(field_get:dmi.UploadDebugInfoStatus.file_name)
+  return file_name_.GetNoArena();
+}
+inline void UploadDebugInfoStatus::set_file_name(const ::std::string& value) {
+  
+  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);
+  // @@protoc_insertion_point(field_set:dmi.UploadDebugInfoStatus.file_name)
+}
+#if LANG_CXX11
+inline void UploadDebugInfoStatus::set_file_name(::std::string&& value) {
+  
+  file_name_.SetNoArena(
+    &::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::move(value));
+  // @@protoc_insertion_point(field_set_rvalue:dmi.UploadDebugInfoStatus.file_name)
+}
+#endif
+inline void UploadDebugInfoStatus::set_file_name(const char* value) {
+  GOOGLE_DCHECK(value != nullptr);
+  
+  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));
+  // @@protoc_insertion_point(field_set_char:dmi.UploadDebugInfoStatus.file_name)
+}
+inline void UploadDebugInfoStatus::set_file_name(const char* value, size_t size) {
+  
+  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),
+      ::std::string(reinterpret_cast<const char*>(value), size));
+  // @@protoc_insertion_point(field_set_pointer:dmi.UploadDebugInfoStatus.file_name)
+}
+inline ::std::string* UploadDebugInfoStatus::mutable_file_name() {
+  
+  // @@protoc_insertion_point(field_mutable:dmi.UploadDebugInfoStatus.file_name)
+  return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline ::std::string* UploadDebugInfoStatus::release_file_name() {
+  // @@protoc_insertion_point(field_release:dmi.UploadDebugInfoStatus.file_name)
+  
+  return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
+}
+inline void UploadDebugInfoStatus::set_allocated_file_name(::std::string* file_name) {
+  if (file_name != nullptr) {
+    
+  } else {
+    
+  }
+  file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);
+  // @@protoc_insertion_point(field_set_allocated:dmi.UploadDebugInfoStatus.file_name)
+}
+
 #ifdef __GNUC__
   #pragma GCC diagnostic pop
 #endif  // __GNUC__
@@ -1936,6 +2654,10 @@
 
 // -------------------------------------------------------------------
 
+// -------------------------------------------------------------------
+
+// -------------------------------------------------------------------
+
 
 // @@protoc_insertion_point(namespace_scope)
 
@@ -1959,6 +2681,16 @@
 inline const EnumDescriptor* GetEnumDescriptor< ::dmi::StartupConfigInfoResponse_Reason>() {
   return ::dmi::StartupConfigInfoResponse_Reason_descriptor();
 }
+template <> struct is_proto_enum< ::dmi::UploadDebugInfoStatus_UploadStatus> : ::std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::dmi::UploadDebugInfoStatus_UploadStatus>() {
+  return ::dmi::UploadDebugInfoStatus_UploadStatus_descriptor();
+}
+template <> struct is_proto_enum< ::dmi::UploadDebugInfoStatus_Reason> : ::std::true_type {};
+template <>
+inline const EnumDescriptor* GetEnumDescriptor< ::dmi::UploadDebugInfoStatus_Reason>() {
+  return ::dmi::UploadDebugInfoStatus_Reason_descriptor();
+}
 
 }  // namespace protobuf
 }  // namespace google
